-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow positional arguments from ArgGroup take value separately #1761
Comments
You can use conflicts function. |
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:
|
Hey @CreepySkeleton - thanks for the thoughtful response! When y'all implement new features like this is it automatically provided in |
Most things are immediately available through I am inclined to remind you that |
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 :) |
#1334 would be one way to improve the subcommand help output. @EverlastingBugstopper The thing that isn't too clear to me is what in the example commands are meant to be literals vs place holders. $ app set key value EX 60 One workaround discussed earlier was subcommands which means If this is about skipping them based on values, this reminds me of |
I opened this issue a while back when I was working on It looks like when they implemented support for setting expiration that it's just a number and there's no way to specify a difference between seconds and milliseconds. (I'd probably implement this today using something like humantime to parse the length of time rather than archaic EX/PX literals that the actual redis implementation uses) |
Thanks for the reply! |
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: