mirror of
https://github.com/nushell/nushell
synced 2024-12-29 06:23:11 +00:00
Bubble up errors passed to complete
(#11313)
Errors passed in `PipelineData::Value` get thrown in `complete` now. Also added two simple tests for the command. Fix #11187 Fix #10204
This commit is contained in:
parent
7d5bd0d6be
commit
020e121391
3 changed files with 20 additions and 0 deletions
|
@ -101,6 +101,8 @@ impl Command for Complete {
|
||||||
|
|
||||||
Ok(Value::record(record, call.head).into_pipeline_data())
|
Ok(Value::record(record, call.head).into_pipeline_data())
|
||||||
}
|
}
|
||||||
|
// bubble up errors from the previous command
|
||||||
|
PipelineData::Value(Value::Error { error, .. }, _) => Err(*error),
|
||||||
_ => Err(ShellError::GenericError {
|
_ => Err(ShellError::GenericError {
|
||||||
error: "Complete only works with external streams".into(),
|
error: "Complete only works with external streams".into(),
|
||||||
msg: "complete only works on external streams".into(),
|
msg: "complete only works on external streams".into(),
|
||||||
|
|
17
crates/nu-command/tests/commands/complete.rs
Normal file
17
crates/nu-command/tests/commands/complete.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
use nu_test_support::nu;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn basic() {
|
||||||
|
let actual = nu!(r#"
|
||||||
|
(^echo a | complete) == {stdout: "a\n", exit_code: 0}
|
||||||
|
"#);
|
||||||
|
|
||||||
|
assert_eq!(actual.out, "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn error() {
|
||||||
|
let actual = nu!("do { not-found } | complete");
|
||||||
|
|
||||||
|
assert!(actual.err.contains("executable was not found"));
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ mod break_;
|
||||||
mod cal;
|
mod cal;
|
||||||
mod cd;
|
mod cd;
|
||||||
mod compact;
|
mod compact;
|
||||||
|
mod complete;
|
||||||
mod config_env_default;
|
mod config_env_default;
|
||||||
mod config_nu_default;
|
mod config_nu_default;
|
||||||
mod continue_;
|
mod continue_;
|
||||||
|
|
Loading…
Reference in a new issue