mirror of
https://github.com/nushell/nushell.git
synced 2025-08-19 13:38:54 +02:00
Plugin explicit flags (#11581)
# Description #11492 fixed flags for builtin commands but I missed that plugins don't use the same `has_flag` that builtins do. This PR addresses this. Unfortunately this means that return value of `has_flag` needs to change from `bool` to `Result<bool, ShellError>` to produce an error when explicit value is not a boolean (just like in case of `has_flag` for builtin commands. It is not possible to check this in `EvaluatedCall::try_from_call` because # User-Facing Changes Passing explicit values to flags of plugin commands (like `--flag=true` `--flag=false`) should work now. BREAKING: changed return value of `EvaluatedCall::has_flag` method from `bool` to `Result<bool, ShellError>` # Tests + Formatting Added tests and updated documentation and examples
This commit is contained in:
@@ -148,3 +148,16 @@ fn semversion_without_passing_field() {
|
||||
assert_eq!(actual.out, "0.1.4");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn explicit_flag() {
|
||||
Playground::setup("plugin_inc_test_6", |dirs, _| {
|
||||
let actual = nu_with_plugins!(
|
||||
cwd: dirs.test(),
|
||||
plugin: ("nu_plugin_inc"),
|
||||
"'0.1.2' | inc --major=false --minor=true --patch=false"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "0.2.0");
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user