From fccbbc723ddd92532739607630f876f434b201a4 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Mon, 27 Jan 2025 23:24:14 +0100 Subject: [PATCH] feat: allow to specify path to run in --- main.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index d55f378..3527177 100644 --- a/main.go +++ b/main.go @@ -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