mirror of
https://github.com/nushell/nushell.git
synced 2024-11-14 20:44:29 +01:00
* rm now uses -f flag to not print anything * changed quiet flag to q not f * Changed value passed to Value::Nothing in rm command
This commit is contained in:
parent
85d1a681c7
commit
926177235c
@ -13,7 +13,7 @@ use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, Spanned,
|
||||
SyntaxShape, Value,
|
||||
SyntaxShape, Type, Value,
|
||||
};
|
||||
|
||||
const GLOB_PARAMS: glob::MatchOptions = glob::MatchOptions {
|
||||
@ -48,6 +48,7 @@ impl Command for Rm {
|
||||
)
|
||||
.switch("recursive", "delete subdirectories recursively", Some('r'))
|
||||
.switch("force", "suppress error when no file", Some('f'))
|
||||
.switch("quiet", "supress output showing files deleted", Some('q'))
|
||||
// .switch("interactive", "ask user to confirm action", Some('i'))
|
||||
.rest(
|
||||
"rest",
|
||||
@ -78,6 +79,7 @@ fn rm(
|
||||
let permanent = call.has_flag("permanent");
|
||||
let recursive = call.has_flag("recursive");
|
||||
let force = call.has_flag("force");
|
||||
let quiet = call.has_flag("quiet");
|
||||
// let interactive = call.has_flag("interactive");
|
||||
|
||||
let ctrlc = engine_state.ctrlc.clone();
|
||||
@ -241,6 +243,8 @@ fn rm(
|
||||
Value::Error {
|
||||
error: ShellError::SpannedLabeledError(msg, e.to_string(), span),
|
||||
}
|
||||
} else if quiet {
|
||||
Value::Nothing { span }
|
||||
} else {
|
||||
let val = format!("deleted {:}", f.to_string_lossy());
|
||||
Value::String { val, span }
|
||||
@ -266,5 +270,6 @@ fn rm(
|
||||
}
|
||||
}
|
||||
})
|
||||
.filter(|x| !matches!(x.get_type(), Type::Nothing))
|
||||
.into_pipeline_data(ctrlc))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user