fix(cli): remove duplicate error output and suppress usage on runtime errors#466
Merged
fix(cli): remove duplicate error output and suppress usage on runtime errors#466
Conversation
… errors - Add SilenceUsage to root command so runtime errors don't print usage info - Remove manual error print in main() that duplicated Cobra's automatic output - Make whoami print "not logged in" as info instead of returning it as error - Fix dash ping double-printing error details then a separate "Error: ping failed" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why we need this PR?
Running
acontext whoami(ordash ping) when not logged in prints the error message twice — once by Cobra automatically and once by manualfmt.Fprintfinmain(). Additionally, runtime errors incorrectly show Usage/help text.Describe your solution
main.gohadfmt.Fprintf(os.Stderr, "Error: %v\n", cmdErr)which duplicated Cobra's built-in error output. Removed it; Cobra handles the printing.SilenceUsage: trueon root command — runtime errors (e.g. API failures, not-logged-in) should not print Usage info. Usage is only useful for argument/syntax errors, which Cobra handles beforeRunE.whoaminot-logged-in is informational, not an error —runWhoaminow prints the message and returnsnilinstead of returning an error. This matchesrunLogout's pattern which already does the same.dash pingstate checks — "no project selected", "no API key", and ping failure now print info and returnnilinstead of returning errors. The ping failure case was double-printing (diagnostic output + separate error return).Implementation Tasks
SilenceUsage: trueto rootCmd inmain.gofmt.Fprintf(os.Stderr, ...)error print inmain()runWhoamito treat not-logged-in as info outputdash pingdouble-print and state-check error returnsImpact Areas
Checklist
devbranch.🤖 Generated with Claude Code