You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd: migrate commands from Run + os.Exit to RunE (part 2 of #27) #58
This is part 2 of #27. Part 1 maps API errors to typed, readable messages in api.Client.handleError. Part 2 makes every command route those errors through one place.
Most commands use Run, print with fmt.Fprintf(os.Stderr, ...) and call os.Exit(1). Others use RunE. The os.Exit paths skip cobra's error handling and deferred cleanup, and every one of them formats its error differently.
Proposal
Convert commands to RunE, returning wrapped errors (fmt.Errorf("failed to …: %w", err)).
Set SilenceUsage (and SilenceErrors, with cu printing the error itself) on the root command, so runtime failures don't print the usage block while flag and argument errors still do.
Activity
timimsms commentedon Nov 18, 2026
Notes from part 1 (#64) for this follow-up:
--debugoutput at the single formatting point, such as the request URL or the raw SDK error. Today the ECODE always appears in parentheses.GetWorkspaceMembersreturns a plain "workspace not found" error; make it a typed not-found error.cu api(internal/cmd/api.go, which uses its own HTTP client) through the same status mapping.errors.IsRetryablenever matches transport errors, so network failures are never retried. Decide whether they should be.