Nushell plugin for interacting with D-Bus
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

set up nushell plugin

+55
+5
.gitignore
··· 12 12 13 13 # MSVC Windows builds of rustc generate these, which store debugging information 14 14 *.pdb 15 + 16 + 17 + # Added by cargo 18 + 19 + /target
+10
Cargo.toml
··· 1 + [package] 2 + name = "nu_plugin_dbus" 3 + version = "0.1.0" 4 + edition = "2021" 5 + 6 + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 + 8 + [dependencies] 9 + nu-plugin = "0.89.0" 10 + nu-protocol = { version = "0.89.0", features = ["plugin"] }
+40
src/main.rs
··· 1 + use nu_plugin::{serve_plugin, MsgPackSerializer, Plugin, EvaluatedCall, LabeledError}; 2 + use nu_protocol::{PluginSignature, Value}; 3 + 4 + fn main() { 5 + serve_plugin(&mut NuPluginDbus, MsgPackSerializer) 6 + } 7 + 8 + struct NuPluginDbus; 9 + 10 + impl Plugin for NuPluginDbus { 11 + fn signature(&self) -> Vec<PluginSignature> { 12 + vec![ 13 + PluginSignature::build("dbus") 14 + .usage("Commands for interacting with D-Bus") 15 + .search_terms(vec!["dbus".into()]) 16 + .category(nu_protocol::Category::Platform), 17 + ] 18 + } 19 + 20 + fn run( 21 + &mut self, 22 + name: &str, 23 + call: &EvaluatedCall, 24 + input: &Value, 25 + ) -> Result<Value, LabeledError> { 26 + match name { 27 + "dbus" => Err(LabeledError { 28 + label: "The `dbus` command requires a subcommand".into(), 29 + msg: "add --help to see subcommands".into(), 30 + span: Some(call.head) 31 + }), 32 + 33 + _ => Err(LabeledError { 34 + label: "Plugin invoked with unknown command name".into(), 35 + msg: "unknown command".into(), 36 + span: Some(call.head) 37 + }) 38 + } 39 + } 40 + }