forked from extern/nushell
Add rest and glob support to 'open' (#8506)
# Description This adds two different features to `open`: * The ability to pass more than one file to `open`. * Support for using globs in the filenames `open` will create a list stream and stream the output if there is more than one file opened Examples: ``` open file1.csv file2.csv file3.csv ``` ``` open *.nu | where $it =~ "echo" ``` # User-Facing Changes Multi-file and glob support in `open`. Original `open` functionality should continue as before. # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date.
This commit is contained in:
@ -222,7 +222,7 @@ fn errors_if_file_not_found() {
|
||||
//
|
||||
// This seems to be not directly affected by localization compared to the OS
|
||||
// provided error message
|
||||
let expected = "(os error 2)";
|
||||
let expected = "not found";
|
||||
|
||||
assert!(
|
||||
actual.err.contains(expected),
|
||||
@ -232,27 +232,28 @@ fn errors_if_file_not_found() {
|
||||
);
|
||||
}
|
||||
|
||||
// FIXME: jt: I think `open` on a directory is confusing. We should make discuss this one a bit more
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn open_dir_is_ls() {
|
||||
Playground::setup("open_dir", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![
|
||||
EmptyFile("yehuda.txt"),
|
||||
EmptyFile("jttxt"),
|
||||
EmptyFile("andres.txt"),
|
||||
]);
|
||||
fn open_wildcard() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open *.nu | where $it =~ echo | length
|
||||
"#
|
||||
));
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
open .
|
||||
| length
|
||||
"#
|
||||
));
|
||||
assert_eq!(actual.out, "3")
|
||||
}
|
||||
|
||||
assert_eq!(actual.out, "3");
|
||||
})
|
||||
#[test]
|
||||
fn open_multiple_files() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
open caco3_plastics.csv caco3_plastics.tsv | get tariff_item | math sum
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "58309279992")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Reference in New Issue
Block a user