From 741d7b9f10dc5c0759f872ac73f3798f6b7ad877 Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko Date: Sat, 30 May 2020 21:31:34 +0300 Subject: [PATCH] Add `rm_always_trash` option to config (#1869) * Add `rm_always_trash` option to config * Add `--permanent` flag to `rm` * `rm`: error if both `-t` and `-p` are present Co-authored-by: Jonathan Turner --- crates/nu-cli/src/commands/rm.rs | 24 +++++++++++++++++-- crates/nu-cli/src/shell/filesystem_shell.rs | 4 +++- docs/commands/config.md | 26 +++++++++++---------- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/crates/nu-cli/src/commands/rm.rs b/crates/nu-cli/src/commands/rm.rs index a48adce27e..e676cf946a 100644 --- a/crates/nu-cli/src/commands/rm.rs +++ b/crates/nu-cli/src/commands/rm.rs @@ -14,6 +14,8 @@ pub struct RemoveArgs { pub recursive: Tagged, #[allow(unused)] pub trash: Tagged, + #[allow(unused)] + pub permanent: Tagged, } #[async_trait] @@ -29,6 +31,11 @@ impl WholeStreamCommand for Remove { "use the platform's recycle bin instead of permanently deleting", Some('t'), ) + .switch( + "permanent", + "don't use recycle bin, delete permanently", + Some('p'), + ) .switch("recursive", "delete subdirectories recursively", Some('r')) .rest(SyntaxShape::Pattern, "the file path(s) to remove") } @@ -48,7 +55,7 @@ impl WholeStreamCommand for Remove { fn examples(&self) -> Vec { vec![ Example { - description: "Delete a file", + description: "Delete or move a file to the system trash (depending on 'rm_always_trash' config option)", example: "rm file.txt", result: None, }, @@ -57,6 +64,11 @@ impl WholeStreamCommand for Remove { example: "rm --trash file.txt", result: None, }, + Example { + description: "Delete a file permanently", + example: "rm --permanent file.txt", + result: None, + }, ] } } @@ -67,7 +79,15 @@ fn rm(args: CommandArgs, registry: &CommandRegistry) -> Result