-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
how to enable -h
/ --help
(short help) + --help-all
(long help)
#4687
Comments
For now, what you will need to do is use Hmm, I'm not finding in the notes why If we do this, we'd need similar for |
cool! are those available in the derive notation? -- or would it be more that I check the arguments manually after |
Yes, those instructions are for doing it manually. let args = Cli::parse();
if args.help {
let mut cmd = Cli::command();
cmd.build();
cmd.print_help();
std::process::exit(0);
} else if args.help_all {
let mut cmd = Cli::command();
cmd.build();
cmd.print_long_help();
std::process::exit(0);
} |
ah neat, unfortunately my case is a little more complicated and I've got subcommands -- so I need something more like: // I just let `help_all` use `action = ArgAction::Help` since it always triggers `long` help anyway!
if matches!(res.command, Some(Commands::Run(Run { help: true, .. }))) {
let mut cmd = Cli::command();
cmd.build();
cmd.find_subcommand_mut("run").unwrap().print_help()?;
std::process::exit(0);
} this works fine for things which don't have any required arguments -- but as soon as there are required arguments it's too late to trigger the |
The main delay here is going back and forth on what this should look like from the API. I figured, rather than worrying about perfection, I'll implement something and we can always change it when v5 comes around |
I feel like I'm always drowning in the help output from `uv` because we have so many options. I basically agree with the commentary in clap-rs/clap#4687 that having different behaviors for `-h` and `--help` is surprising. I think `--help` is more obvious for users and I want to optimize for that experience. This roughly matches the help menus in Cargo and pip. The `uv help` command can be used for long help. In #4906 and #4909 we improve that command. Extends #4904 which adds test cases for the existing behavior.
Please complete the following tasks
Clap Version
4.1.4
Describe your use case
I've found #3405 which hints at the same idea, but I wasn't able to follow whether this was implemented or not
I have this, which is close but doesn't satisfy the "--help gives short help" (mostly, I find
clap
's choice of-h
and--help
an odd one, and not one I've found precedence for elsewhere, the more common approach I've seen is--help-all
or--help-full
or--help-{thing}
to give additional help for specific areas).Describe the solution you'd like
maybe something like this?
(
HelpShort
/HelpLong
)Alternatives, if applicable
I am very new to
clap
, so I'd be happy enough if there's already a solution to thisAdditional Context
for example,
python
's help:The text was updated successfully, but these errors were encountered: