mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Make to text
stream ListStreams (#7577)
This PR changes `to text` so that when given a `ListStream`, it streams the incoming values instead of collecting them all first. The easiest way to observe/verify this PR is to convert a list to a very slow `ListStream` with `each`: ```bash ls | get name | each {|n| sleep 1sec; $n} | to text ``` The `to text` output will appear 1 item at a time.
This commit is contained in:
19
crates/nu-command/tests/commands/to_text.rs
Normal file
19
crates/nu-command/tests/commands/to_text.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn list_to_text() {
|
||||
let actual = nu!(r#"["foo" "bar" "baz"] | to text"#);
|
||||
|
||||
// these actually have newlines between them in the real world but nu! strips newlines, grr
|
||||
assert_eq!(actual.out, "foobarbaz");
|
||||
}
|
||||
|
||||
// the output should be the same when `to text` gets a ListStream instead of a Value::List
|
||||
#[test]
|
||||
fn list_stream_to_text() {
|
||||
// use `each` to convert the list to a ListStream
|
||||
let actual = nu!(r#"["foo" "bar" "baz"] | each {|i| $i} | to text"#);
|
||||
|
||||
// these actually have newlines between them in the real world but nu! strips newlines, grr
|
||||
assert_eq!(actual.out, "foobarbaz");
|
||||
}
|
Reference in New Issue
Block a user