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
Last argument needs to be quoted #1344
Comments
Any updates? Is the project still maintained? |
If it's of anyones interest: By default, clap will only parse any argument once. This means that in I'm assuming you want all of the non-option arguments instead of just one, in which case setting let matches = App::new("foo")
.version("0.1")
.arg(
Arg::with_name("user")
.short("u")
.long("user")
.required(true)
.takes_value(true),
)
.arg(
Arg::with_name("command")
.help("The command to run")
.required(true)
.takes_value(true)
.multiple(true),
)
// parse as if program ran as: foo -u jack echo s
.get_matches_from(&["foo", "-u", "jack", "echo", "s"]);
// get command arguments
let command: Vec<&str> = matches.values_of("command").unwrap().collect();
println!("{:?}", command); // ["echo", "s"] |
Rust Version
rustc 1.27.0 (3eda71b00 2018-06-19)
Affected Version of clap
Expected Behavior Summary
My command line tool is supposed to work like this
foo -u <user> <command>
e.g.:
foo -u jack echo s
foo -u paul ls -al
So, I need to get options such as user, but the
<command>
itself, I need to be therest
of the args.Actual Behavior Summary
The code below, results on a behavior where I can't get the value of
<command>
unless is quoted:foo -u jack echo s
->error: Found argument 's' which wasn't expected, or isn't valid in this context
whereas:
foo -u jack 'echo s'
works fine.Is there anyway of avoiding the quotes?
Sample Code or Link to Sample Code
The text was updated successfully, but these errors were encountered: