diff --git a/README.md b/README.md index df79842..960162c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ A wrapper for the "rm" command with soft-deletes, config-based deletion, debug i - `-i` Interactivly prompt before each deletion request - `-I` Prompt if deleting more than the interactive threshold of files (default 3) - `-r`, `-R`, `--recursive` Recursively delete a directory of files +- `-v`, `--verbose` Emit additional verbose information - `--help` Display help information (without deletion) - `--version` Display version information (without deletion) @@ -26,9 +27,6 @@ A wrapper for the "rm" command with soft-deletes, config-based deletion, debug i ## Unsupported command line arguments - `-d`, `--dir` Only delete empty directories -- `-v`, `--verbose` Emit additional verbose information -- `--version` Show version information -- `--help` Show help information - `--interactive[=WHEN]` Interactive with a custom threshold - `--one-file-system` Do not allow cross-file-system deletes - `-f`, `--force` Bypass protections diff --git a/src/cli/args.go b/src/cli/args.go index 8e52158..05f284f 100644 --- a/src/cli/args.go +++ b/src/cli/args.go @@ -9,6 +9,9 @@ const BYPASS_PROTECTED_CLA = "--bypass-protected" const OVERWRITE_CLA = "--overwrite" const NOTIFICATION_CLA = "--notify" +const VERBOSE_CLA = "--verbose" +const VERBOSE_SHORT_CLA = "-v" + // gnu rm CLI arguments const INTERACTIVE_CLA = "-i" const INTERACTIVE_GROUP_CLA = "-I" diff --git a/src/cli/docs.go b/src/cli/docs.go index 42e19c9..e055749 100644 --- a/src/cli/docs.go +++ b/src/cli/docs.go @@ -11,11 +11,19 @@ Mark FILE(s) for deletion. "GNU Like" OPTION(s): -i Prompt before every deletion request +-r, -R, --recursive Remove directories and their contents recursively + -I Prompt once before deleting more than the interactive threshold (default 3) -f, --force Bypass protections +-v, --verbose Add additional information to the output + +--help Display this help and (without deleting anything) + +--version Output version information (without deleting anything) + 2rm OPTION(s) Flags: --overwrite Overwrite the disk location location with zeros diff --git a/src/patches/rm.go b/src/patches/rm.go index 49184c9..f16f819 100644 --- a/src/patches/rm.go +++ b/src/patches/rm.go @@ -113,12 +113,18 @@ func deletePaths(paths []string, config models.Config, arguments []string) { forceSoftDelete := util.InArray(arguments, cli.SOFT_DELETE_CLA) bypassProtected := util.InArray(arguments, cli.BYPASS_PROTECTED_CLA) overwrite := util.InArray(arguments, cli.OVERWRITE_CLA) + silent := util.InArray(arguments, cli.SILENT_CLA) hasInteraciveCla := util.InArray(arguments, cli.INTERACTIVE_CLA) hasGroupInteractiveCla := util.InArray(arguments, cli.INTERACTIVE_GROUP_CLA) isInteractiveGroup := hasGroupInteractiveCla && len(paths) >= config.InteractiveThreshold() isInteractive := hasInteraciveCla || isInteractiveGroup + hasVerboseCla := util.InArray(arguments, cli.VERBOSE_CLA) + if !hasVerboseCla { + hasVerboseCla = util.InArray(arguments, cli.VERBOSE_SHORT_CLA) + } + for _, path := range paths { if isInteractive { fmt.Println("Are you sure you want to delete", path, "? (y/n)") @@ -159,6 +165,10 @@ func deletePaths(paths []string, config models.Config, arguments []string) { shouldHardDelete := isTmp || forceHardDelete || isConfigHardDelete && !isConfigSoftDelete && !forceSoftDelete deletePath(absolutePath, shouldHardDelete, config) + + if hasVerboseCla && !silent { + fmt.Printf("removed '%s'\n", path) + } } }