Skip to content

Commit

Permalink
Refactor noconfirm flag handling and update usage message
Browse files Browse the repository at this point in the history
  • Loading branch information
sammy fischer committed Jan 6, 2025
1 parent 81a3db3 commit 483225a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,31 @@ func containsSubstring(path string, exclude []string) bool {
return false
}

func isFlagPassed(name string) bool {
found := false
flag.Visit(func(f *flag.Flag) {
if f.Name == name {
found = true
}
})
return found
}

func main() {
var directory string
var mode string
var noconfirm bool
var excludeParam string
fmt.Printf("CopyCure %v (written by Sammy Fischer)\n", version)
flag.StringVar(&directory, "i", "", "Directory to scan for duplicates")
flag.StringVar(&mode, "m", "sql", "Mode: 'sql' or 'mem'")
flag.BoolVar(&noconfirm, "y", true, "Delete files without asking")
_ = flag.Bool("y", false, "Delete files without asking")
flag.StringVar(&excludeParam, "e", "", "Comma separated list of partial filenames to exclude (e.g. -e .venv/,.git/)")
flag.Parse()
exclude := strings.Split(excludeParam, ",")

noconfirm := isFlagPassed("y")
if directory == "" {
fmt.Println("Usage: copycure -i /path/to/your/directory [-m sql|mem] [-c] [-v]\n" +
fmt.Println("Usage: copycure -i /path/to/your/directory [-m sql|mem] [-c] [-e aaa,bbb]\n" +
" -m : method to store known checksums\n" +
" -y : remove files without asking\n" +
" -e : comma separated list of partial filenames to exclude (e.g. -e .venv,.git )")
Expand Down

0 comments on commit 483225a

Please sign in to comment.