package main import ( "os" "strings" "github.com/warrenronsiek/ctask/cmd" ) // version and commit are populated at release build time via: // // go build -ldflags "-X main.version=vX.Y.Z -X main.commit=" // // Defaults below apply when the binary is built without ldflags (e.g. // `go build`, `just install`) so local development still produces a // runnable binary whose `--version` output is unambiguous. var ( version = "dev" commit = "" ) func main() { cmd.SetVersionInfo(version, commit) if err := cmd.Execute(); err != nil { msg := err.Error() // Exit code 127 for agent command not found (per spec) if strings.Contains(msg, "agent command not found") { os.Exit(127) } // Exit code 2 for missing required arguments (per spec) if strings.Contains(msg, "accepts") && strings.Contains(msg, "received 0") { os.Exit(2) } os.Exit(1) } }