-
-
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
how to parse mv <files>... <target>
?
#725
Comments
This is because there's no way to know when There are two ways to fix this, either swap the arguments (i.e. Hope this helps! I'm also open to suggestions 😉 |
mv <files> <target>
?mv <files>... <target>
?
Also, thinking about this a little more, there may be a way I could add this feature. Let me play with some implementations and get back with you! |
…l argument as multiple(true) Now one can build CLIs that support things like `mv <files>... <target>` There are a few requirements and caveats; * The final positional argument (and all positional arguments prior) *must* be required * Only one positional argument may be `multiple(true)` * Only the second to last, or last positional argument may be `multiple(true)` Closes #725
I found a way to make this work, after #727 merges I'll upload v2.17.0 to crates.io At which point this will give the expected results: let m = App::new()
.arg(Arg::with_name("files").required(true).multiple(true))
.arg(Arg::with_name("target").required(true))
.get_matches(); |
@hh9527 v2.17.0 is up on crates.io now |
waooo, it is so nice of you! thank you for this great project! |
@kbknapp I have tried v2.17.0, it works without subcommand, but still break in subcommand. This works: let m = App::new("mv")
.arg(Arg::with_name("paths").required(true).multiple(true))
.arg(Arg::with_name("target").required(true))
.get_matches(); And this not: let m = App::new("cli")
.subcommand(
SubCommand::with_name("mv")
.arg(Arg::with_name("paths").required(true).multiple(true))
.arg(Arg::with_name("target").required(true))
).get_matches(); |
Ah, thanks for pointing this out, I hadn't testsed it after a subcommand, only before! |
It's fixed in #730 😉 |
v2.17.1 is up now! |
E.g.:
mv a1 a2 a3/
I use the code like this:
When input
mv a1 a2 a3/
, I expect result like this:But I got a error:
The text was updated successfully, but these errors were encountered: