-
Notifications
You must be signed in to change notification settings - Fork 18.9k
adding nicer help when missing arguments #11858
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
Conversation
|
@jasinner can you add some text explaining what you did and why? For example, is this just going to show the usage stuff w/o the full options list? And why did you change the exit code from non-zero to zero? Giving people some rationale behind your PR will help move it along. I agree that the current stuff is lacking and I'm not sure why the more verbose stuff was removed. isn't nearly as useful as what we used to show, which was the full --help output. |
|
@duglin This change prints a short usage output, with the format of the command, when incorrect arguments are passed to a command. Like you said, currently at the moment the usage output is not very friendly as it only shows the number of argument required. This change not only shows that output, but the format of the command passed into the flags.subCmd method. If users want the full, verbose output of the the flag.Usage command they can call --help. I agree that the exit code on shortUsage should be 1. I will change it on Monday if required. |
api/client/cli.go
Outdated
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.
remove the Exit from here
|
@jasinner yes please :) |
|
Hi guys, I added some more commits. Please review. |
api/client/cli.go
Outdated
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.
To ensure consistency, should these 2 lines be replaced with a call to flags.ShortUsage() ?
|
When done, please merge your commits down to one. |
|
@jasinner ping |
|
@duglin The file utils/flags.go was removed from upstream master, so it was removed from my commit. |
|
@jasinner I think you lost your "signed-off by" stuff during your squashing. Try doing: and then pushing again to see if that fixes it. |
Signed-off-by: Jason Shepherd <jason@jasonshepherd.net>
|
@duglin added signed-off by |
|
thanks! |
api/client/cli.go
Outdated
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.
This is a redundant else.
|
As is here is the output from And the output of |
|
Passing --help to save is not the same output, it shows all the arguments. with --help |
Signed-off-by: Jason Shepherd <jason@jasonshepherd.net>
|
Hi @duglin and @GordonTheTurtle I run gofmt, and attempted to fix up the signature. I hope I got everything correct, but let me know if there is anything outstanding. Jason |
|
@jasinner you'll need to squash your commits down to one. That should make Gordon happy, assuming that one commit is signed. |
Signed-off-by: Jason Shepherd <jason@jasonshepherd.net>
Signed-off-by: Jason Shepherd <jason@jasonshepherd.net>
|
ping @duglin I see this PR was updated, PTAL |
|
@jasinner it looks good. Sorry for not mentioning this earlier, but I think we need a few testcases added. In particular, I think ones that:
|
|
@jfrazelle I'll work on the testcases either tonight or tomorrow. if @jasinner doesn't respond by, say, Sunday maybe we can grab both sets of changes. |
|
Or do you need it sooner? |
|
thanks SGTM On Fri, May 22, 2015 at 5:01 PM, Doug Davis notifications@github.com
|
Continues 11858 by: - Making sure the exit code is always zero when we ask for help - Making sure the exit code isn't zero when we print help on error cases - Making sure both short and long usage go to the same stream (stdout vs stderr) - Making sure all docker commands support --help - Test that all cmds send --help to stdout, exit code 0, show full usage, no blank lines at end - Test that all cmds (that support it) show short usage on bad arg to stderr, no blank line at end - Test that all cmds complain about a bad option, no blank line at end - Test that docker (w/o subcmd) does the same stuff mentioned above properly Signed-off-by: Doug Davis <dug@us.ibm.com>
|
@jasinner I just did PR #13428 to continue this PR - mainly to add new testcases. I did however find some oddities in the way some things were done for some commands, so I fixed those too. Now we should be consistent. Hope you're ok with this. We're coming up on the deadline for v1.7 and we wanted to make sure this made it in. |
Continues 11858 by: - Making sure the exit code is always zero when we ask for help - Making sure the exit code isn't zero when we print help on error cases - Making sure both short and long usage go to the same stream (stdout vs stderr) - Making sure all docker commands support --help - Test that all cmds send --help to stdout, exit code 0, show full usage, no blank lines at end - Test that all cmds (that support it) show short usage on bad arg to stderr, no blank line at end - Test that all cmds complain about a bad option, no blank line at end - Test that docker (w/o subcmd) does the same stuff mentioned above properly Signed-off-by: Doug Davis <dug@us.ibm.com>
|
This has been merged on master as part of #13428. Closing! 😄 |
|
@vieux @jfrazelle according to #11858 (comment) you wanted this in the 1.7 release? |
|
ill cherry pick it |
Signed-off-by: Jason Shepherd <jason@jasonshepherd.net> (cherry picked from commit 48231d6)
|
@duglin thanks for finishing this off. Happy to see it get merged. On Sunday, 24 May 2015, Doug Davis notifications@github.com wrote:
|
Signed-off-by: Jason Shepherd <jason@jasonshepherd.net>
Continues 11858 by: - Making sure the exit code is always zero when we ask for help - Making sure the exit code isn't zero when we print help on error cases - Making sure both short and long usage go to the same stream (stdout vs stderr) - Making sure all docker commands support --help - Test that all cmds send --help to stdout, exit code 0, show full usage, no blank lines at end - Test that all cmds (that support it) show short usage on bad arg to stderr, no blank line at end - Test that all cmds complain about a bad option, no blank line at end - Test that docker (w/o subcmd) does the same stuff mentioned above properly Signed-off-by: Doug Davis <dug@us.ibm.com>
Continues 11858 by: - Making sure the exit code is always zero when we ask for help - Making sure the exit code isn't zero when we print help on error cases - Making sure both short and long usage go to the same stream (stdout vs stderr) - Making sure all docker commands support --help - Test that all cmds send --help to stdout, exit code 0, show full usage, no blank lines at end - Test that all cmds (that support it) show short usage on bad arg to stderr, no blank line at end - Test that all cmds complain about a bad option, no blank line at end - Test that docker (w/o subcmd) does the same stuff mentioned above properly Signed-off-by: Doug Davis <dug@us.ibm.com> (cherry picked from commit 8324d79)
Signed-off-by: Jason Shepherd <jason@jasonshepherd.net>
Continues 11858 by: - Making sure the exit code is always zero when we ask for help - Making sure the exit code isn't zero when we print help on error cases - Making sure both short and long usage go to the same stream (stdout vs stderr) - Making sure all docker commands support --help - Test that all cmds send --help to stdout, exit code 0, show full usage, no blank lines at end - Test that all cmds (that support it) show short usage on bad arg to stderr, no blank line at end - Test that all cmds complain about a bad option, no blank line at end - Test that docker (w/o subcmd) does the same stuff mentioned above properly Signed-off-by: Doug Davis <dug@us.ibm.com>
Signed-off-by: Jason Shepherd jason@jasonshepherd.net