64 breaking releases
0.87.1 | Nov 20, 2023 |
---|---|
0.86.0 | Oct 17, 2023 |
0.83.1 | Jul 30, 2023 |
0.77.1 | Mar 17, 2023 |
0.12.0 | Mar 31, 2020 |
#51 in Cryptography
7,588 downloads per month
Used in 57 crates
(55 directly)
1MB
19K
SLoC
Nu Plugin: Plugin library for Nushell
This crate contains the interface necessary to build Nushell plugins in Rust. Additionally, it contains public, but undocumented, items used by Nushell itself to interface with Nushell plugins. This documentation focuses on the interface needed to write an independent plugin.
Nushell plugins are stand-alone applications that communicate with Nushell over stdin and stdout using a standardizes serialization framework to exchange the typed data that Nushell commands utilize natively.
A typical plugin application will define a struct that implements the [Plugin] trait and then, in it's main method, pass that [Plugin] to the [serve_plugin] function, which will handle all of the input and output serialization when invoked by Nushell.
use nu_plugin::{EvaluatedCall, LabeledError, MsgPackSerializer, Plugin, serve_plugin};
use nu_protocol::{PluginSignature, Value};
struct MyPlugin;
impl Plugin for MyPlugin {
fn signature(&self) -> Vec<PluginSignature> {
todo!();
}
fn run(
&mut self,
name: &str,
call: &EvaluatedCall,
input: &Value
) -> Result<Value, LabeledError> {
todo!();
}
}
fn main() {
serve_plugin(&mut MyPlugin{}, MsgPackSerializer)
}
Nushell's source tree contains a Plugin Example that demonstrates the full range of plugin capabilities.
Dependencies
~12–24MB
~336K SLoC