diff --git a/cmd/archive.go b/cmd/archive.go index 08a4b98..9915c71 100644 --- a/cmd/archive.go +++ b/cmd/archive.go @@ -11,10 +11,11 @@ import ( ) var archiveCmd = &cobra.Command{ - Use: "archive ", - Short: "Mark a workspace as archived", - Args: cobra.ExactArgs(1), - RunE: runArchive, + Use: "archive ", + Short: "Mark a workspace as archived", + Args: cobra.ExactArgs(1), + SilenceUsage: true, + RunE: runArchive, } func init() { diff --git a/cmd/info.go b/cmd/info.go index 014a476..8fb7838 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -11,8 +11,9 @@ import ( var infoCmd = &cobra.Command{ Use: "info ", Short: "Display metadata and path for a workspace", - Args: cobra.ExactArgs(1), - RunE: runInfo, + Args: cobra.ExactArgs(1), + SilenceUsage: true, + RunE: runInfo, } var infoAll bool diff --git a/cmd/list.go b/cmd/list.go index 313db2c..4c38a96 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -14,8 +14,9 @@ import ( var listCmd = &cobra.Command{ Use: "list", Short: "Show recent workspaces in reverse-chronological order", - Args: cobra.NoArgs, - RunE: runList, + Args: cobra.NoArgs, + SilenceUsage: true, + RunE: runList, } var ( diff --git a/cmd/new.go b/cmd/new.go index 58d7114..a91e32c 100644 --- a/cmd/new.go +++ b/cmd/new.go @@ -13,8 +13,9 @@ var newCmd = &cobra.Command{ Use: "new [title]", Short: "Create a new task workspace and launch the agent", Long: "Create a new task workspace and launch the agent. If title is omitted, generates task-HHMMSS.", - Args: cobra.MaximumNArgs(1), - RunE: runNew, + Args: cobra.MaximumNArgs(1), + SilenceUsage: true, + RunE: runNew, } var ( diff --git a/cmd/open.go b/cmd/open.go index cadcd5c..4afc3b6 100644 --- a/cmd/open.go +++ b/cmd/open.go @@ -12,10 +12,11 @@ import ( ) var openCmd = &cobra.Command{ - Use: "open ", - Short: "Open a workspace directory without launching the agent", - Args: cobra.ExactArgs(1), - RunE: runOpen, + Use: "open ", + Short: "Open a workspace directory without launching the agent", + Args: cobra.ExactArgs(1), + SilenceUsage: true, + RunE: runOpen, } var openAll bool diff --git a/cmd/resume.go b/cmd/resume.go index eaaf571..3603f90 100644 --- a/cmd/resume.go +++ b/cmd/resume.go @@ -12,10 +12,11 @@ import ( ) var resumeCmd = &cobra.Command{ - Use: "resume ", - Short: "Reopen an existing workspace and launch the agent", - Args: cobra.ExactArgs(1), - RunE: runResume, + Use: "resume ", + Short: "Reopen an existing workspace and launch the agent", + Args: cobra.ExactArgs(1), + SilenceUsage: true, + RunE: runResume, } var ( diff --git a/main.go b/main.go index ba5c36f..61bad87 100644 --- a/main.go +++ b/main.go @@ -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) } } +