Skip to content

Commit

Permalink
Add --dry-run flag
Browse files Browse the repository at this point in the history
  • Loading branch information
hudson-newey committed Sep 30, 2024
1 parent c7baa97 commit 4f9f7df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Wraps the rm command with a more secure, safer, and more private version
- `--hard` Do not soft-delete file
- `--soft` Soft delete a file. A backup will be stored in `/tmp/2rm`
- `--silent` Do not print out additional information priduced by 2rm. This is useful for scripting situations.
- `--dry-run` Perform a dry run and show all the files that would be deleted

## Features

Expand Down Expand Up @@ -53,10 +54,10 @@ You can specify what directories are soft-deleted anb hard-deleted by using the
# backed up in the `backups` directory
backups: /tmp/2rm/
hard:
- node_modules/
- target/
- .angular/
- .next/
- "node_modules/"
- "target/"
- ".angular/"
- ".next/"
# always soft delete backup files,
# regardless of it they are configured
# for a hard delete
Expand Down
6 changes: 6 additions & 0 deletions src/patches/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ const TRASH_DIR_PERMISSIONS = 0755
const HARD_DELETE_CLA = "--hard"
const SOFT_DELETE_CLA = "--soft"
const SILENT_CLA = "--silent"
const DRY_RUN_CLA = "--dry-run"

func RmPatch(arguments []string, config models.Config) {
forceHardDelete := util.InArray(arguments, HARD_DELETE_CLA)
forceSoftDelete := util.InArray(arguments, SOFT_DELETE_CLA)
silent := util.InArray(arguments, SILENT_CLA)
dryRun := util.InArray(arguments, DRY_RUN_CLA)

actionedArgs := removeUnNeededArguments(
removeDangerousArguments(arguments),
Expand All @@ -43,6 +45,10 @@ func RmPatch(arguments []string, config models.Config) {
fmt.Println(debugStatement)
}

if dryRun {
return
}

for _, path := range filePaths {
absolutePath := relativeToAbsolute(path)
isTmp := isTmpPath(absolutePath)
Expand Down

0 comments on commit 4f9f7df

Please sign in to comment.