Add ctrl_c to RunnablePerItemContext. (#1239)

Also, this commit makes `ls` a per-item command.

A command that processes things item by item may still take some time to stream
out the results from a single item. For example, `ls` on a directory with a lot
of files could be interrupted in the middle of showing all of these files.
This commit is contained in:
Jason Gedge
2020-01-18 21:25:07 -05:00
committed by Jonathan Turner
parent 3abfefc025
commit 47d987d37f
14 changed files with 79 additions and 42 deletions

View File

@ -69,3 +69,29 @@ fn lists_regular_files_using_question_mark_wildcard() {
assert_eq!(actual, "3");
})
}
#[test]
fn lists_all_files_in_directories_from_stream() {
Playground::setup("ls_test_4", |dirs, sandbox| {
sandbox.mkdir("dir_a").mkdir("dir_b").with_files(vec![
EmptyFile("root1.txt"),
EmptyFile("root2.txt"),
EmptyFile("dir_a/yehuda.10.txt"),
EmptyFile("dir_a/jonathan.10.txt"),
EmptyFile("dir_b/andres.10.txt"),
EmptyFile("dir_b/chicken_not_to_be_picked_up.100.txt"),
]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
echo dir_a dir_b
| ls $it
| count
| echo $it
"#
));
assert_eq!(actual, "4");
})
}