clap/tests/derive/structopt.rs
Ed Page 06d43a02da fix(help): Subcommand help looks like --help
Like was said in #2435, this is what people would expect.

While we should note this in a compatibility section in the changelog, I
do not consider this a breaking change since we should be free to adjust
the help output as needed.  We are cautious when people might build up
their own content around it (like #3312) but apps should already handle
this with `--help` so this shouldn't be a major change.

We aren't offering a way for people to disable this, assuming people
won't need to.  Longer term, we are looking at support "Actions" (#3405)
and expect those to help customize the flags.  We'll need something
similar for the `help` subcommand.

Fixes #3440
2022-02-11 12:47:34 -06:00

23 lines
528 B
Rust

#![allow(deprecated)]
use clap::{AppSettings, StructOpt};
#[test]
fn compatible() {
#[derive(StructOpt)]
#[structopt(author, version, about)]
#[structopt(global_setting(AppSettings::PropagateVersion))]
struct Cli {
#[structopt(subcommand)]
command: Commands,
}
#[derive(StructOpt)]
#[structopt(setting(AppSettings::SubcommandRequiredElseHelp))]
enum Commands {
/// Adds files to myapp
Add { name: Option<String> },
}
Cli::from_iter(["test", "add"]);
}