mirror of
https://github.com/nushell/nushell.git
synced 2025-05-05 23:42:56 +00:00
# Description As suggested by @WindSoilder, since plugins can now contain both simple commands that produce `Value` and commands that produce `PipelineData` without having to choose one or the other for the whole plugin, this change merges `stream_example` into `example`. # User-Facing Changes All of the example plugins are renamed. # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting - [ ] Check nushell/nushell.github.io for any docs that match the command names changed
42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
use nu_plugin::{EngineInterface, EvaluatedCall, LabeledError, SimplePluginCommand};
|
|
use nu_protocol::{Category, PluginSignature, Value};
|
|
|
|
use crate::Example;
|
|
|
|
pub struct Main;
|
|
|
|
impl SimplePluginCommand for Main {
|
|
type Plugin = Example;
|
|
|
|
fn signature(&self) -> PluginSignature {
|
|
PluginSignature::build("example")
|
|
.usage("Example commands for Nushell plugins")
|
|
.extra_usage(
|
|
r#"
|
|
The `example` plugin demonstrates usage of the Nushell plugin API.
|
|
|
|
Several commands provided to test and demonstrate different capabilities of
|
|
plugins exposed through the API. None of these commands are intended to be
|
|
particularly useful.
|
|
"#
|
|
.trim(),
|
|
)
|
|
.search_terms(vec!["example".into()])
|
|
.category(Category::Experimental)
|
|
}
|
|
|
|
fn run(
|
|
&self,
|
|
_plugin: &Self::Plugin,
|
|
_engine: &EngineInterface,
|
|
call: &EvaluatedCall,
|
|
_input: &Value,
|
|
) -> Result<Value, LabeledError> {
|
|
Err(LabeledError {
|
|
label: "No subcommand provided".into(),
|
|
msg: "add --help to see a list of subcommands".into(),
|
|
span: Some(call.head),
|
|
})
|
|
}
|
|
}
|