-
Notifications
You must be signed in to change notification settings - Fork 574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rpk/api: Return back friendly errors #362
Conversation
@c4milo really great idea! thank you. looks like some simple test strings need to be updated. waiting for the go mod patch to finish building and I'll merge that too. |
when positional arguments are missing. Instead of Cobra's generic errors.
5bea0d0
to
d3379dc
Compare
@0x5d, @senior7515, this is ready for review. FWIW, I got caught up by |
Args: cobra.ExactArgs(1), | ||
Args: exactArgs(1, "topic's name is missing."), | ||
// We don't want Cobra printing CLI usage help if the error isn't about CLI usage. | ||
SilenceUsage: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we are using Cobra's RunE
function, any errors returned from it will make Cobra to automatically print the Usage help, even if the error has nothing to do with CLI usage. We may want to use Cobra differently after GA, to have more flexibility on CLI UX.
@senior7515, it was @rkruze idea :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
when positional arguments are missing in all subcommands of
rpk api
. Instead ofCobra's generic errors. Fixes half of #300.
Before
After