From 8827bd8ccb1d4f7787ca758809f864ae59b1e50e Mon Sep 17 00:00:00 2001 From: takeshi yamashita <220619+takecy@users.noreply.github.com> Date: Sun, 26 Apr 2026 17:12:38 +0900 Subject: [PATCH] refactor(gih): clean up version handling and arg formatting Co-Authored-By: Claude --- gih/main.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/gih/main.go b/gih/main.go index 09e4126..93dff25 100644 --- a/gih/main.go +++ b/gih/main.go @@ -12,8 +12,7 @@ import ( // set by build var ( - version = "0.16.0" - goversion = "1.26.2" + version = "0.16.0" ) const usage = `Run git command to all repositories in the current directory. @@ -54,15 +53,9 @@ func main() { return } - if flag.Arg(0) == "version" { - _, err := fmt.Fprintf(os.Stdout, "git-here %s\n", version) - if err != nil { - panic(err) - } - _, err = fmt.Fprintf(os.Stdout, "go version %s\n", goversion) - if err != nil { - panic(err) - } + switch flag.Arg(0) { + case "version": + printVersion() return } @@ -70,7 +63,7 @@ func main() { *conNum = runtime.NumCPU() } - fmt.Printf("args: targetDir: %s ignoreDir: %s concurrency: %d timeout: %v\n", *targetDir, *ignoreDir, *conNum, *timeout) + fmt.Printf("args: targetDir: %s ignoreDir: %s concurrency: %d timeout: %v\n", *targetDir, *ignoreDir, *conNum, *timeout) writer := os.Stdout errWriter := os.Stderr @@ -98,3 +91,14 @@ func main() { os.Exit(2) } } + +func printVersion() { + _, err := fmt.Fprintf(os.Stdout, "git-here %s\n", version) + if err != nil { + panic(err) + } + _, err = fmt.Fprintf(os.Stdout, "go version %s\n", runtime.Version()) + if err != nil { + panic(err) + } +}