Rename flag parameter to not clash with subcommand

This commit is contained in:
Felipe Sere 2021-05-19 19:42:39 +01:00
parent 03d4989ef9
commit 6bac0c53bf

View file

@ -166,7 +166,7 @@ fn global_passed_down() {
#[derive(Debug, PartialEq, Clap)]
struct Opt {
#[clap(global = true, long)]
global: bool,
other: bool,
#[clap(subcommand)]
sub: Subcommands,
}
@ -180,22 +180,22 @@ fn global_passed_down() {
#[derive(Debug, PartialEq, Clap)]
struct GlobalCmd {
#[clap(from_global)]
global: bool,
other: bool,
}
assert_eq!(
Opt::parse_from(&["test", "global"]),
Opt {
global: false,
sub: Subcommands::Global(GlobalCmd { global: false })
other: false,
sub: Subcommands::Global(GlobalCmd { other: false })
}
);
assert_eq!(
Opt::parse_from(&["test", "global", "--global"]),
Opt::parse_from(&["test", "global", "--other"]),
Opt {
global: true,
sub: Subcommands::Global(GlobalCmd { global: true })
other: true,
sub: Subcommands::Global(GlobalCmd { other: true })
}
);
}