fix: exit codes match spec (0, 1, 2, 127) and silence usage on runtime errors
Exit 2 for missing required arguments, exit 127 for agent not found. SilenceUsage on all commands to avoid dumping usage on runtime errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,12 +2,23 @@ package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/warrenronsiek/ctask/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user