-
Notifications
You must be signed in to change notification settings - Fork 0
Allow positional arguments from ArgGroup take value separately #145
Comments
Comment by CreepySkeleton I'm under impression that This is pretty interesting question. What he's asking for (or so I get it) is:
But non-positional options must start with I'll take liberty to rename this issue, transforming it into feature request. Until the, @EverlastingBugstopper , you can make use of subcommands: use clap::{App, Arg, SubCommand};
fn main() {
let m = App::new("app")
.subcommand(SubCommand::with_name("PX")
.arg(Arg::with_name("value").takes_value(true).required(true)))
.subcommand(SubCommand::with_name("EX")
.arg(Arg::with_name("value").takes_value(true).required(true)))
.get_matches();
println!("{:#?}", m);
}
The only thing is that the error message might not appear what you want:
|
Comment by EverlastingBugstopper Hey @CreepySkeleton - thanks for the thoughtful response! When y'all implement new features like this is it automatically provided in |
Comment by CreepySkeleton
Most things are immediately available through I am inclined to remind you that |
Comment by EverlastingBugstopper Awesome! Yeah - this is something I'm working on the side, not released or intended to be released soon so it's ok that it's still in alpha. Thanks for the help :) |
Issue by EverlastingBugstopper
Wednesday Mar 25, 2020 at 17:37 GMT
Originally opened as clap-rs/clap#1761
What are you trying to do?
I'm trying to create positional command line arguments that are exclusive, you can either set one or the other. I'd like to be able to use clap_derive with this so that they are boiled down to a single
expiration: std::time::Duration
field in an opt struct.set expiration to 60 seconds
$ app set key value EX 60
set expiration to 6000 milliseconds
$ app set key value PX 6000
What have you tried already?
I haven't been sure what to try or if this is even supported :)
The text was updated successfully, but these errors were encountered: