I'm using clap and I get a unexpected behaviour when trying to parse arguments.
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
I need to get options such as user, but the <command>
itself, I need to be the rest of the args.
The code below results in a behavior where I can't get the value of <command>
unless it is quoted:
foo -u jack echo s
error: Found argument 's' which wasn't expected, or isn't valid in this context
Whereas this works fine:
foo -u jack 'echo s'
Is there any way of avoiding the quotes?
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),
)
.get_matches();
I've also opened an issue on the clap repository.