-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
A-helpArea: documentation, including docs.rs, readme, examples, etc...Area: documentation, including docs.rs, readme, examples, etc...C-enhancementCategory: Raise on the bar on expectationsCategory: Raise on the bar on expectationsS-waiting-on-decisionStatus: Waiting on a go/no-go before implementingStatus: Waiting on a go/no-go before implementing
Description
Please complete the following tasks
- I have searched the discussions
- I have searched the open and rejected issues
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).
use clap::Parser;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
#[clap(disable_help_flag = true)]
struct Cli {
/// Should always be shown in all helps
#[arg(long)]
someopt: String,
/// Secret option, should only be shown in --help-all
#[arg(long, hide_short_help = true)]
wacky: String,
/// Print help
#[arg(short, long, action = clap::ArgAction::Help)]
help: bool,
/// Print help, including uncommon options
#[arg(long, action = clap::ArgAction::Help)]
help_all: bool,
}
fn main() {
let args = Cli::parse();
println!("Hello, world!, {:?}", args);
}
Describe the solution you'd like
maybe something like this?
/// Print help
#[arg(short, long, action = clap::ArgAction::HelpShort)]
help: bool,
/// Print help, including uncommon options
#[arg(long, action = clap::ArgAction::HelpLong)]
help_all: bool,
(HelpShort
/ HelpLong
)
Alternatives, if applicable
I am very new to clap
, so I'd be happy enough if there's already a solution to this
Additional Context
for example, python
's help:
$ python3.12 --help
usage: python3.12 [option] ... [-c cmd | -m mod | file | -] [arg] ...
Options (and corresponding environment variables):
-b : issue warnings about str(bytes_instance), str(bytearray_instance)
and comparing bytes/bytearray with str. (-bb: issue errors)
...
--help-env : print help about Python environment variables and exit
--help-xoptions : print help about implementation-specific -X options and exit
--help-all : print complete help information and exit
Arguments:
file : program read from script file
- : program read from stdin (default; interactive mode if a tty)
arg ...: arguments passed to program in sys.argv[1:]
broadwaylamb
Metadata
Metadata
Assignees
Labels
A-helpArea: documentation, including docs.rs, readme, examples, etc...Area: documentation, including docs.rs, readme, examples, etc...C-enhancementCategory: Raise on the bar on expectationsCategory: Raise on the bar on expectationsS-waiting-on-decisionStatus: Waiting on a go/no-go before implementingStatus: Waiting on a go/no-go before implementing