Skip to content

Commit

Permalink
No prompt on empty in quiet mode.
Browse files Browse the repository at this point in the history
As one might use rem in a script, it is needed to
give a way to empty the trash with no prompt. I
reused the quiet flag for that purpose.
  • Loading branch information
Arkaeriit committed Jun 30, 2022
1 parent c0b9d0b commit 8cf338e
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions rem.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ var (
helpMsg = `Rem - Get some rem sleep knowing your files are safe
Rem is a CLI Trash
Usage: rem [-t/--set-dir <dir>] [--disable-copy] [--permanent | -u/--undo] <file> ...
rem [-d/--directory | --empty | -h/--help | -v/--version | -l/--list]
rem [-d/--directory | --empty | -h/--help | -v/--version | -l/--list]
Options:
-u/--undo restore a file
-l/--list list files in trash
--empty empty the trash permanently
--permanent delete a file permanently
-d/--directory show path to the data dir
-t/--set-dir <dir> set the data dir and continue
-q/--quiet enable quiet mode
--disable-copy if files are on a different fs, don't rename by copy
-h/--help print this help message
-v/--version print Rem version`
-u/--undo restore a file
-l/--list list files in trash
--empty empty the trash permanently
--permanent delete a file permanently
-d/--directory show path to the data dir
-t/--set-dir <dir> set the data dir and continue
-q/--quiet enable quiet mode
--disable-copy if files are on a different fs, don't rename by copy
-h/--help print this help message
-v/--version print Rem version`
dataDir string
logFileName = ".trash.log"
logFile map[string]string
Expand Down Expand Up @@ -100,9 +100,13 @@ func main() {
return
}
if hasOption, _ := argsHaveOptionLong("empty"); hasOption {
color.Red("Warning, permanently deleting all files in " + dataDir + "/trash")
if promptBool("Confirm delete?") {
if quietMode {
emptyTrash()
} else {
color.Red("Warning, permanently deleting all files in " + dataDir + "/trash")
if promptBool("Confirm delete?") {
emptyTrash()
}
}
return
}
Expand Down

0 comments on commit 8cf338e

Please sign in to comment.