mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Add -i
flag back to get
and select
(#8488)
https://github.com/nushell/nushell/pull/8379 removed the `-i` flag from `get` and `select` because the new `?` functionality covers most of the same use cases. However, https://github.com/nushell/nushell/issues/8480 made me realize that `-i` is still useful when dealing with cell paths in variables. This PR re-adds the `-i` flag to `get` and `select`. It works by just marking every member in the cell path as optional, which will behave _slightly_ differently than `-i` used to (previously it would suppress any errors, even type errors) but IMO that's OK.
This commit is contained in:
@ -241,3 +241,16 @@ fn get_does_not_delve_too_deep_in_nested_lists() {
|
||||
|
||||
assert!(actual.err.contains("cannot find column"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignore_errors_works() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
let path = "foo";
|
||||
{} | get -i $path | to nuon
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "null");
|
||||
}
|
||||
|
@ -256,3 +256,16 @@ fn select_failed4() {
|
||||
|
||||
assert!(actual.err.contains("Select can't get the same row twice"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignore_errors_works() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
let path = "foo";
|
||||
[{}] | select -i $path | to nuon
|
||||
"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "[[foo]; [null]]");
|
||||
}
|
||||
|
Reference in New Issue
Block a user