feat: allow to specify path to run in
This commit is contained in:
parent
09cbbef45d
commit
fccbbc723d
19
main.go
19
main.go
@ -21,25 +21,34 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
flag.BoolVar(&dryrun, "n", false, "Show what would have been done.")
|
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()
|
flag.Parse()
|
||||||
|
|
||||||
switch flag.Arg(0) {
|
switch flag.Arg(0) {
|
||||||
case "normalize":
|
case "normalize":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "n":
|
case "n":
|
||||||
filepath.Walk(".", normalize)
|
err := filepath.Walk(*path, normalize)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
case "removesuffix":
|
case "removesuffix":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "rs":
|
case "rs":
|
||||||
suffix := args[1]
|
suffix := args[1]
|
||||||
filepath.Walk(".", removeSuffix(suffix))
|
err := filepath.Walk(*path, removeSuffix(suffix))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
removeSuffix(suffix)
|
removeSuffix(suffix)
|
||||||
break
|
|
||||||
case "unpack":
|
case "unpack":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "up":
|
case "up":
|
||||||
filepath.Walk(".", unpack)
|
err := filepath.Walk(*path, unpack)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
fmt.Println("Invalid action specified")
|
fmt.Println("Invalid action specified")
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user