use nu_plugin::{MsgPackSerializer, Plugin, PluginCommand, SimplePluginCommand, serve_plugin}; use nu_protocol::{LabeledError, Signature, Type, Value}; struct MyPlugin; impl Plugin for MyPlugin { fn version(&self) -> String { env!("CARGO_PKG_VERSION").into() } fn commands(&self) -> Vec>> { vec![Box::new(MyCommand)] } } struct MyCommand; impl SimplePluginCommand for MyCommand { type Plugin = MyPlugin; fn name(&self) -> &str { "mynu" } fn signature(&self) -> nu_protocol::Signature { Signature::build(PluginCommand::name(self)).input_output_type(Type::String, Type::String) } fn description(&self) -> &str { "A learning rust plugin" } fn run( &self, _plugin: &Self::Plugin, _engine: &nu_plugin::EngineInterface, _call: &nu_plugin::EvaluatedCall, input: &nu_protocol::Value, ) -> Result { match input { Value::String { val, .. } => { Ok(Value::string(format!("Hello, {}!", val), input.span())) } _ => Err(LabeledError::new("Expected String input").into()), } } } fn main() { serve_plugin(&MyPlugin {}, MsgPackSerializer) }