Something went wrong. Try again.
Nushell plugin for interacting with D-Bus
Something went wrong. Try again.
2.2 kB · 80 lines
Rust
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081use nu_plugin::{MsgPackSerializer, Plugin, PluginCommand, serve_plugin};use nu_protocol::SyntaxShape;
mod client;mod commands;mod config;mod convert;mod dbus_type;mod introspection;mod pattern;
fn main() { serve_plugin(&NuPluginDbus, MsgPackSerializer)}
/// The main plugin interface for nushellpub struct NuPluginDbus;
impl Plugin for NuPluginDbus { fn version(&self) -> String { env!("CARGO_PKG_VERSION").into() }
fn commands(&self) -> Vec<Box<dyn PluginCommand<Plugin = Self>>> { vec![ Box::new(commands::Main), Box::new(commands::Introspect), Box::new(commands::Call), Box::new(commands::Get), Box::new(commands::GetAll), Box::new(commands::Set), Box::new(commands::List), ] }}
/// For conveniently adding the base options to a dbus commandtrait DbusSignatureUtilExt { fn dbus_command(self) -> Self; fn accepts_dbus_client_options(self) -> Self; fn accepts_timeout(self) -> Self;}
impl DbusSignatureUtilExt for nu_protocol::Signature { fn dbus_command(self) -> Self { self.category(nu_protocol::Category::Platform) }
fn accepts_dbus_client_options(self) -> Self { self.switch("session", "Send to the session message bus (default)", None) .switch("system", "Send to the system message bus", None) .switch( "started", "Send to the bus that started this process, if applicable", None, ) .named( "bus", SyntaxShape::String, "Send to the bus server at the given address", None, ) .named( "peer", SyntaxShape::String, "Send to a non-bus D-Bus server at the given address. \ Will not call the Hello method on initialization.", None, ) }
fn accepts_timeout(self) -> Self { self.named( "timeout", SyntaxShape::Duration, "How long to wait for a response", None, ) }}