feat: allow to specify path to run in

This commit is contained in:
Jan Bader 2025-01-27 23:24:14 +01:00
parent 09cbbef45d
commit fccbbc723d

19
main.go
View File

@ -21,25 +21,34 @@ func main() {
}
flag.BoolVar(&dryrun, "n", false, "Show what would have been done.")
flag.StringVar(&execCmd, "exec", "", "Run commant on matching file.")
flag.StringVar(&execCmd, "exec", "", "Run command on matching file.")
path := flag.String("path", "p", "Handle files in path.")
flag.Parse()
switch flag.Arg(0) {
case "normalize":
fallthrough
case "n":
filepath.Walk(".", normalize)
err := filepath.Walk(*path, normalize)
if err != nil {
panic(err)
}
case "removesuffix":
fallthrough
case "rs":
suffix := args[1]
filepath.Walk(".", removeSuffix(suffix))
err := filepath.Walk(*path, removeSuffix(suffix))
if err != nil {
panic(err)
}
removeSuffix(suffix)
break
case "unpack":
fallthrough
case "up":
filepath.Walk(".", unpack)
err := filepath.Walk(*path, unpack)
if err != nil {
panic(err)
}
default:
fmt.Println("Invalid action specified")
return