display help instead of silently exiting on empty subcommands - #978
Merged
Conversation
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.
Previously, running commands without arguments had inconsistent UX
Commands with optional arguments, like suggestions, mouse, editor would parse successfully, do nothing and silently exit:

Commands with required arguments, like perf, create-prompt-widget would print a help menu without any colour on the fonts and return a non-zero exit code (notice the red > on the screenshot):

What i did was adding
arg_required_else_help = trueto all subcommands that currently exit silently when no arguments are passed to it. I also updated the match arm in cli.rs to correctly handleErrorKind::DisplayHelpOnMissingArgumentOrSubcommand, now it should print help menu and exit successfully. Also addedcolor = clap::ColorChoice::Alwaysto FlylineArgs for consistency.Here is what it looks like after:
