mirror of
https://github.com/nushell/nushell.git
synced 2025-03-13 15:08:43 +01:00
# Description The `PluginSignature` type supports extra usage but this was not available in `plugin_name --help`. It also supports search terms but these did not appear in `help commands` New behavior show below is the "Extra usage for nu-example-1" line and the "Search terms:" line ``` ❯ nu-example-1 --help PluginSignature test 1 for plugin. Returns Value::Nothing Extra usage for nu-example-1 Search terms: example Usage: > nu-example-1 {flags} <a> <b> (opt) ...(rest) Flags: -h, --help - Display the help message for this command -f, --flag - a flag for the signature -n, --named <String> - named string Parameters: a <int>: required integer value b <string>: required string value opt <int>: Optional number (optional) ...rest <string>: rest value string Examples: running example with an int value and string value > nu-example-1 3 bb ``` Search terms are also available in `help commands`: ``` ❯ help commands | where name == "nu-example-1" | select name search_terms ╭──────────────┬──────────────╮ │ name │ search_terms │ ├──────────────┼──────────────┤ │ nu-example-1 │ example │ ╰──────────────┴──────────────╯ ``` # User-Facing Changes Users can now see plugin extra usage and search terms # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
30 lines
821 B
Rust
30 lines
821 B
Rust
use nu_test_support::nu_with_plugins;
|
|
use nu_test_support::playground::Playground;
|
|
|
|
#[test]
|
|
fn help() {
|
|
Playground::setup("help", |dirs, _| {
|
|
let actual = nu_with_plugins!(
|
|
cwd: dirs.test(),
|
|
plugin: ("nu_plugin_example"),
|
|
"nu-example-1 --help"
|
|
);
|
|
|
|
assert!(actual.out.contains("PluginSignature test 1"));
|
|
assert!(actual.out.contains("Extra usage for nu-example-1"));
|
|
})
|
|
}
|
|
|
|
#[test]
|
|
fn search_terms() {
|
|
Playground::setup("search_terms", |dirs, _| {
|
|
let actual = nu_with_plugins!(
|
|
cwd: dirs.test(),
|
|
plugin: ("nu_plugin_example"),
|
|
r#"help commands | where name == "nu-example-1" | echo $"search terms: ($in.search_terms)""#
|
|
);
|
|
|
|
assert!(actual.out.contains("search terms: [example]"));
|
|
})
|
|
}
|