forked from extern/nushell
remove without check path exist, rm -f
(#2590)
This commit is contained in:
@ -16,6 +16,7 @@ pub struct RemoveArgs {
|
||||
pub trash: Tagged<bool>,
|
||||
#[allow(unused)]
|
||||
pub permanent: Tagged<bool>,
|
||||
pub force: Tagged<bool>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
@ -37,6 +38,7 @@ impl WholeStreamCommand for Remove {
|
||||
Some('p'),
|
||||
)
|
||||
.switch("recursive", "delete subdirectories recursively", Some('r'))
|
||||
.switch("force", "suppress error when no file", Some('f'))
|
||||
.rest(SyntaxShape::Pattern, "the file path(s) to remove")
|
||||
}
|
||||
|
||||
@ -69,6 +71,11 @@ impl WholeStreamCommand for Remove {
|
||||
example: "rm --permanent file.txt",
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "Delete a file, and suppress errors if no file is found",
|
||||
example: "rm --force file.txt",
|
||||
result: None,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -496,6 +496,7 @@ impl Shell for FilesystemShell {
|
||||
recursive,
|
||||
trash: _trash,
|
||||
permanent: _permanent,
|
||||
force: _force,
|
||||
}: RemoveArgs,
|
||||
name: Tag,
|
||||
path: &str,
|
||||
@ -556,7 +557,7 @@ impl Shell for FilesystemShell {
|
||||
};
|
||||
}
|
||||
|
||||
if all_targets.is_empty() {
|
||||
if all_targets.is_empty() && !_force.item {
|
||||
return Err(ShellError::labeled_error(
|
||||
"No valid paths",
|
||||
"no valid paths",
|
||||
|
Reference in New Issue
Block a user