mirror of
https://github.com/nushell/nushell.git
synced 2025-04-11 23:08:20 +02: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::engine::{Command, EngineState, Stack};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, Spanned,
|
Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, Spanned,
|
||||||
SyntaxShape, Value,
|
SyntaxShape, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
const GLOB_PARAMS: glob::MatchOptions = glob::MatchOptions {
|
const GLOB_PARAMS: glob::MatchOptions = glob::MatchOptions {
|
||||||
@ -48,6 +48,7 @@ impl Command for Rm {
|
|||||||
)
|
)
|
||||||
.switch("recursive", "delete subdirectories recursively", Some('r'))
|
.switch("recursive", "delete subdirectories recursively", Some('r'))
|
||||||
.switch("force", "suppress error when no file", Some('f'))
|
.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'))
|
// .switch("interactive", "ask user to confirm action", Some('i'))
|
||||||
.rest(
|
.rest(
|
||||||
"rest",
|
"rest",
|
||||||
@ -78,6 +79,7 @@ fn rm(
|
|||||||
let permanent = call.has_flag("permanent");
|
let permanent = call.has_flag("permanent");
|
||||||
let recursive = call.has_flag("recursive");
|
let recursive = call.has_flag("recursive");
|
||||||
let force = call.has_flag("force");
|
let force = call.has_flag("force");
|
||||||
|
let quiet = call.has_flag("quiet");
|
||||||
// let interactive = call.has_flag("interactive");
|
// let interactive = call.has_flag("interactive");
|
||||||
|
|
||||||
let ctrlc = engine_state.ctrlc.clone();
|
let ctrlc = engine_state.ctrlc.clone();
|
||||||
@ -241,6 +243,8 @@ fn rm(
|
|||||||
Value::Error {
|
Value::Error {
|
||||||
error: ShellError::SpannedLabeledError(msg, e.to_string(), span),
|
error: ShellError::SpannedLabeledError(msg, e.to_string(), span),
|
||||||
}
|
}
|
||||||
|
} else if quiet {
|
||||||
|
Value::Nothing { span }
|
||||||
} else {
|
} else {
|
||||||
let val = format!("deleted {:}", f.to_string_lossy());
|
let val = format!("deleted {:}", f.to_string_lossy());
|
||||||
Value::String { val, span }
|
Value::String { val, span }
|
||||||
@ -266,5 +270,6 @@ fn rm(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.filter(|x| !matches!(x.get_type(), Type::Nothing))
|
||||||
.into_pipeline_data(ctrlc))
|
.into_pipeline_data(ctrlc))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user