mirror of
https://github.com/nushell/nushell.git
synced 2025-08-16 17:51:42 +02:00
Merge stream_example into example plugin and clean up names (#12234)
# 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
This commit is contained in:
@ -15,7 +15,7 @@ fn closure() {
|
||||
}
|
||||
}
|
||||
}
|
||||
nu-example-config
|
||||
example config
|
||||
"#
|
||||
);
|
||||
|
||||
@ -27,7 +27,7 @@ fn none() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests",
|
||||
plugin: ("nu_plugin_example"),
|
||||
"nu-example-config"
|
||||
"example config"
|
||||
);
|
||||
|
||||
assert!(actual.err.contains("No config sent"));
|
||||
@ -47,7 +47,7 @@ fn record() {
|
||||
}
|
||||
}
|
||||
}
|
||||
nu-example-config
|
||||
example config
|
||||
"#
|
||||
);
|
||||
|
||||
|
@ -7,9 +7,9 @@ fn get_env_by_name() {
|
||||
plugin: ("nu_plugin_example"),
|
||||
r#"
|
||||
$env.FOO = bar
|
||||
nu-example-env FOO | print
|
||||
example env FOO | print
|
||||
$env.FOO = baz
|
||||
nu-example-env FOO | print
|
||||
example env FOO | print
|
||||
"#
|
||||
);
|
||||
assert!(result.status.success());
|
||||
@ -21,7 +21,7 @@ fn get_envs() {
|
||||
let result = nu_with_plugins!(
|
||||
cwd: ".",
|
||||
plugin: ("nu_plugin_example"),
|
||||
"$env.BAZ = foo; nu-example-env | get BAZ"
|
||||
"$env.BAZ = foo; example env | get BAZ"
|
||||
);
|
||||
assert!(result.status.success());
|
||||
assert_eq!("foo", result.out);
|
||||
@ -37,7 +37,7 @@ fn get_current_dir() {
|
||||
let result = nu_with_plugins!(
|
||||
cwd: ".",
|
||||
plugin: ("nu_plugin_example"),
|
||||
"cd tests; nu-example-env --cwd"
|
||||
"cd tests; example env --cwd"
|
||||
);
|
||||
assert!(result.status.success());
|
||||
assert_eq!(cwd, result.out);
|
||||
@ -48,7 +48,7 @@ fn set_env() {
|
||||
let result = nu_with_plugins!(
|
||||
cwd: ".",
|
||||
plugin: ("nu_plugin_example"),
|
||||
"nu-example-env NUSHELL_OPINION --set=rocks; $env.NUSHELL_OPINION"
|
||||
"example env NUSHELL_OPINION --set=rocks; $env.NUSHELL_OPINION"
|
||||
);
|
||||
assert!(result.status.success());
|
||||
assert_eq!("rocks", result.out);
|
||||
|
@ -7,11 +7,11 @@ fn help() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: dirs.test(),
|
||||
plugin: ("nu_plugin_example"),
|
||||
"nu-example-1 --help"
|
||||
"example one --help"
|
||||
);
|
||||
|
||||
assert!(actual.out.contains("PluginSignature test 1"));
|
||||
assert!(actual.out.contains("Extra usage for nu-example-1"));
|
||||
assert!(actual.out.contains("Extra usage for example one"));
|
||||
})
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ fn search_terms() {
|
||||
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)""#
|
||||
r#"help commands | where name == "example one" | echo $"search terms: ($in.search_terms)""#
|
||||
);
|
||||
|
||||
assert!(actual.out.contains("search terms: [example]"));
|
||||
|
@ -5,8 +5,8 @@ use pretty_assertions::assert_eq;
|
||||
fn seq_produces_stream() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"stream_example seq 1 5 | describe"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"example seq 1 5 | describe"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "list<int> (stream)");
|
||||
@ -20,8 +20,8 @@ fn seq_describe_no_collect_succeeds_without_error() {
|
||||
for _ in 0..10 {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"stream_example seq 1 5 | describe --no-collect"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"example seq 1 5 | describe --no-collect"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "stream");
|
||||
@ -33,16 +33,16 @@ fn seq_describe_no_collect_succeeds_without_error() {
|
||||
fn seq_stream_collects_to_correct_list() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"stream_example seq 1 5 | to json --raw"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"example seq 1 5 | to json --raw"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "[1,2,3,4,5]");
|
||||
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"stream_example seq 1 0 | to json --raw"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"example seq 1 0 | to json --raw"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "[]");
|
||||
@ -53,8 +53,8 @@ fn seq_big_stream() {
|
||||
// Testing big streams helps to ensure there are no deadlocking bugs
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"stream_example seq 1 100000 | length"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"example seq 1 100000 | length"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "100000");
|
||||
@ -64,8 +64,8 @@ fn seq_big_stream() {
|
||||
fn sum_accepts_list_of_int() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"[1 2 3] | stream_example sum"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"[1 2 3] | example sum"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "6");
|
||||
@ -75,8 +75,8 @@ fn sum_accepts_list_of_int() {
|
||||
fn sum_accepts_list_of_float() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"[1.0 2.0 3.5] | stream_example sum"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"[1.0 2.0 3.5] | example sum"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "6.5");
|
||||
@ -86,8 +86,8 @@ fn sum_accepts_list_of_float() {
|
||||
fn sum_accepts_stream_of_int() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"seq 1 5 | stream_example sum"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"seq 1 5 | example sum"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "15");
|
||||
@ -97,8 +97,8 @@ fn sum_accepts_stream_of_int() {
|
||||
fn sum_accepts_stream_of_float() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"seq 1 5 | into float | stream_example sum"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"seq 1 5 | into float | example sum"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "15");
|
||||
@ -109,8 +109,8 @@ fn sum_big_stream() {
|
||||
// Testing big streams helps to ensure there are no deadlocking bugs
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"seq 1 100000 | stream_example sum"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"seq 1 100000 | example sum"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "5000050000");
|
||||
@ -120,8 +120,8 @@ fn sum_big_stream() {
|
||||
fn collect_external_accepts_list_of_string() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"[a b] | stream_example collect-external"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"[a b] | example collect-external"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "ab");
|
||||
@ -131,8 +131,8 @@ fn collect_external_accepts_list_of_string() {
|
||||
fn collect_external_accepts_list_of_binary() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"[0x[41] 0x[42]] | stream_example collect-external"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"[0x[41] 0x[42]] | example collect-external"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "AB");
|
||||
@ -142,8 +142,8 @@ fn collect_external_accepts_list_of_binary() {
|
||||
fn collect_external_produces_raw_input() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"[a b c] | stream_example collect-external | describe"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"[a b c] | example collect-external | describe"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "raw input");
|
||||
@ -155,12 +155,12 @@ fn collect_external_big_stream() {
|
||||
// time without deadlocking
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
plugin: ("nu_plugin_example"),
|
||||
r#"(
|
||||
seq 1 10000 |
|
||||
to text |
|
||||
each { into string } |
|
||||
stream_example collect-external |
|
||||
example collect-external |
|
||||
lines |
|
||||
length
|
||||
)"#
|
||||
@ -173,8 +173,8 @@ fn collect_external_big_stream() {
|
||||
fn for_each_prints_on_stderr() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"[a b c] | stream_example for-each { $in }"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"[a b c] | example for-each { $in }"
|
||||
);
|
||||
|
||||
assert_eq!(actual.err, "a\nb\nc\n");
|
||||
@ -184,8 +184,8 @@ fn for_each_prints_on_stderr() {
|
||||
fn generate_sequence() {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: "tests/fixtures/formats",
|
||||
plugin: ("nu_plugin_stream_example"),
|
||||
"stream_example generate 0 { |i| if $i <= 10 { {out: $i, next: ($i + 2)} } } | to json --raw"
|
||||
plugin: ("nu_plugin_example"),
|
||||
"example generate 0 { |i| if $i <= 10 { {out: $i, next: ($i + 2)} } } | to json --raw"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "[0,2,4,6,8,10]");
|
||||
|
Reference in New Issue
Block a user