
Rust Version
rustc 1.42.0 (b8cedc004 2020-03-09)
Code
use clap;
use clap::Arg;
use clap::ArgGroup;
fn main() {
let app = clap::App::new("hello")
.bin_name("deno")
.arg(
Arg::with_name("option1")
.long("option1")
.takes_value(false),
)
.arg(
Arg::with_name("pos1")
.takes_value(true),
)
.group(
ArgGroup::with_name("arg1")
.args(&["pos1", "option1"])
.required(true),
)
.arg(
Arg::with_name("pos2")
.takes_value(true)
);
match app.get_matches_from_safe(std::env::args().collect::<Vec<String>>()) {
Ok(_) => (),
Err(err) => err.exit(),
}
}
Steps to reproduce the issue
cargo run -- -h
Affected Version of clap*
2.33.0
Actual Behavior Summary
USAGE:
deno <pos1|--option1> [pos1]
cargo run -- --option1 abcd binds abcd to pos1 and complains about conflict between option1 and pos1
Blocks denoland/deno#4635, ref denoland/deno#4635 (comment).
Expected Behavior Summary
USAGE:
deno <pos1|--option1> [pos2]
cargo run -- --option1 abcd should bind abcd to pos2. In other words, it should detect --option1 having been given as an option and accordingly skip pos1 which --option1 is grouped with.
--
If this is actually intended I welcome suggestions as to how I can get the above behaviour. But what else should be the semantics of grouping positional args with options?
IssueHunt Summary
Backers (Total: $20.00)
Tips
Rust Version
rustc 1.42.0 (b8cedc004 2020-03-09)Code
Steps to reproduce the issue
cargo run -- -hAffected Version of
clap*2.33.0
Actual Behavior Summary
cargo run -- --option1 abcdbindsabcdtopos1and complains about conflict betweenoption1andpos1Blocks denoland/deno#4635, ref denoland/deno#4635 (comment).
Expected Behavior Summary
cargo run -- --option1 abcdshould bindabcdtopos2. In other words, it should detect--option1having been given as an option and accordingly skippos1which--option1is grouped with.--
If this is actually intended I welcome suggestions as to how I can get the above behaviour. But what else should be the semantics of grouping positional args with options?
IssueHunt Summary
Backers (Total: $20.00)
Become a backer now!
Or submit a pull request to get the deposits!
Tips