-
Notifications
You must be signed in to change notification settings - Fork 287
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
cmd/cue: fix help cmd incorrect behavior #2759
Conversation
This would need a test; see the other Also, I suspect this will break existing tests. Did you run them? |
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.
See the above
This fixes the issue of incorrect behavior when requesting help for an unknown command in the CUE CLI. 1. Modified the `newHelpCmd` function to handle unknown commands correctly. 2. When an unknown `cue help` commands are entered, an error message is displayed and the program exits with a non-zero status code. 3. This ensures that the CLI behaves as expected and provides useful feedback to the user when an unknown command is entered. Fixes cue-lang#2560 Signed-off-by: nnnkkk7 <[email protected]> Signed-off-by: nnnkkk7 <[email protected]>
82ee1cf
to
697b950
Compare
thanks! i fixed it! |
See the above - if you are fixing a bug, a test should be added. See https://github.com/cue-lang/cue/blob/master/CONTRIBUTING.md |
Signed-off-by: nnnkkk7 <[email protected]>
@mvdan |
Thanks! No need to write a Go test and mock os.Exit for this; we already have integration tests for cmd/go at cmd/cue/cmd/testdata/script/help.txtar and sibling files like help_cmd.txtar, for example. Also, is there a particular reason that you swapped Printf and CheckErr for PrintErrf and os.Exit? As far as I can tell, the fix here is the addition of |
We cover all edge cases now; a missing help command, sub-command, and "cmd" command, as well as all the valid help combinations. Note that for unknown "cmd" commands we print a more precise error, and we also check that custom commands are added to the help text in all cases where we print help text for cmd. We join help_hello.txtar with help_cmd.txtar given their overlap. Thanks to Naoki Kuroda for proposing a version of the fix in #2759 which was adapted here, along with more testscript coverage. Fixes #2560. Fixes #2918. Closes #2759 as partially merged. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I252e57c59eab499e40daea45355f1da75acba249
Did the above, as well as added more test cases, in this Gerrit patch: https://review.gerrithub.io/c/cue-lang/cue/+/1194247 Hope that's okay with you, and please let me know if you spot any issues there. |
This fixes the issue of incorrect behavior when requesting help for an unknown command in the CUE CLI.
newHelpCmd
function to handle unknown commands correctly.cue help
commands are entered, an error message is displayed and the program exits with a non-zero status code.Fixes #2560