-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Labels
A-helpArea: documentation, including docs.rs, readme, examples, etc...Area: documentation, including docs.rs, readme, examples, etc...A-parsingArea: Parser's logic and needs it changed somehow.Area: Parser's logic and needs it changed somehow.C-bugCategory: bugCategory: bugS-waiting-on-decisionStatus: Waiting on a go/no-go before implementingStatus: Waiting on a go/no-go before implementing
Description
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)
pksunkara ($20.00)
Become a backer now!
Or submit a pull request to get the deposits!
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.
Metadata
Metadata
Assignees
Labels
A-helpArea: documentation, including docs.rs, readme, examples, etc...Area: documentation, including docs.rs, readme, examples, etc...A-parsingArea: Parser's logic and needs it changed somehow.Area: Parser's logic and needs it changed somehow.C-bugCategory: bugCategory: bugS-waiting-on-decisionStatus: Waiting on a go/no-go before implementingStatus: Waiting on a go/no-go before implementing