mirror of
https://github.com/nushell/nushell.git
synced 2024-11-26 02:13:47 +01:00
nu-command/filters: drop column check positive value (#6412)
This commit is contained in:
parent
7b502a4c7f
commit
918ec9daa8
@ -49,6 +49,13 @@ impl Command for DropColumn {
|
||||
1
|
||||
};
|
||||
|
||||
// Make columns to drop is positive
|
||||
if columns_to_drop < 0 {
|
||||
if let Some(expr) = call.positional_nth(0) {
|
||||
return Err(ShellError::NeedsPositiveValue(expr.span));
|
||||
}
|
||||
}
|
||||
|
||||
dropcol(engine_state, span, input, columns_to_drop)
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,17 @@ fn columns() {
|
||||
assert_eq!(actual.out, "1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drop_columns_positive_value() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(r#"
|
||||
echo [[a, b];[1,2]] | drop column -1
|
||||
"#)
|
||||
);
|
||||
|
||||
assert!(actual.err.contains("use a positive value"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn more_columns_than_table_has() {
|
||||
let actual = nu!(
|
||||
|
Loading…
Reference in New Issue
Block a user