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:
Devyn Cairns
2024-03-19 10:36:46 -07:00
committed by GitHub
parent 02551c416c
commit a29efe28f7
28 changed files with 197 additions and 305 deletions

View File

@ -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]");