Skip to content

Commit 8a484e5

Browse files
committed
Add -v and --verbose flags
1 parent ede28f3 commit 8a484e5

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ A wrapper for the "rm" command with soft-deletes, config-based deletion, debug i
99
- `-i` Interactivly prompt before each deletion request
1010
- `-I` Prompt if deleting more than the interactive threshold of files (default 3)
1111
- `-r`, `-R`, `--recursive` Recursively delete a directory of files
12+
- `-v`, `--verbose` Emit additional verbose information
1213
- `--help` Display help information (without deletion)
1314
- `--version` Display version information (without deletion)
1415

@@ -26,9 +27,6 @@ A wrapper for the "rm" command with soft-deletes, config-based deletion, debug i
2627
## Unsupported command line arguments
2728

2829
- `-d`, `--dir` Only delete empty directories
29-
- `-v`, `--verbose` Emit additional verbose information
30-
- `--version` Show version information
31-
- `--help` Show help information
3230
- `--interactive[=WHEN]` Interactive with a custom threshold
3331
- `--one-file-system` Do not allow cross-file-system deletes
3432
- `-f`, `--force` Bypass protections

src/cli/args.go

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const BYPASS_PROTECTED_CLA = "--bypass-protected"
99
const OVERWRITE_CLA = "--overwrite"
1010
const NOTIFICATION_CLA = "--notify"
1111

12+
const VERBOSE_CLA = "--verbose"
13+
const VERBOSE_SHORT_CLA = "-v"
14+
1215
// gnu rm CLI arguments
1316
const INTERACTIVE_CLA = "-i"
1417
const INTERACTIVE_GROUP_CLA = "-I"

src/cli/docs.go

+8
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ Mark FILE(s) for deletion.
1111
"GNU Like" OPTION(s):
1212
-i Prompt before every deletion request
1313
14+
-r, -R, --recursive Remove directories and their contents recursively
15+
1416
-I Prompt once before deleting more than the interactive
1517
threshold (default 3)
1618
1719
-f, --force Bypass protections
1820
21+
-v, --verbose Add additional information to the output
22+
23+
--help Display this help and (without deleting anything)
24+
25+
--version Output version information (without deleting anything)
26+
1927
2rm OPTION(s) Flags:
2028
2129
--overwrite Overwrite the disk location location with zeros

src/patches/rm.go

+10
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,18 @@ func deletePaths(paths []string, config models.Config, arguments []string) {
113113
forceSoftDelete := util.InArray(arguments, cli.SOFT_DELETE_CLA)
114114
bypassProtected := util.InArray(arguments, cli.BYPASS_PROTECTED_CLA)
115115
overwrite := util.InArray(arguments, cli.OVERWRITE_CLA)
116+
silent := util.InArray(arguments, cli.SILENT_CLA)
116117

117118
hasInteraciveCla := util.InArray(arguments, cli.INTERACTIVE_CLA)
118119
hasGroupInteractiveCla := util.InArray(arguments, cli.INTERACTIVE_GROUP_CLA)
119120
isInteractiveGroup := hasGroupInteractiveCla && len(paths) >= config.InteractiveThreshold()
120121
isInteractive := hasInteraciveCla || isInteractiveGroup
121122

123+
hasVerboseCla := util.InArray(arguments, cli.VERBOSE_CLA)
124+
if !hasVerboseCla {
125+
hasVerboseCla = util.InArray(arguments, cli.VERBOSE_SHORT_CLA)
126+
}
127+
122128
for _, path := range paths {
123129
if isInteractive {
124130
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) {
159165
shouldHardDelete := isTmp || forceHardDelete || isConfigHardDelete && !isConfigSoftDelete && !forceSoftDelete
160166

161167
deletePath(absolutePath, shouldHardDelete, config)
168+
169+
if hasVerboseCla && !silent {
170+
fmt.Printf("removed '%s'\n", path)
171+
}
162172
}
163173
}
164174

0 commit comments

Comments
 (0)