I have a program foo
that uses Clap to handle command argument parsing. foo
invokes another program, bar
. Recently, I decided that users of foo
should be able to pass arguments to bar
if they like. I added the bar
command to Clap:
let matches = App::new("Foo")
.arg(Arg::with_name("file").value_name("FILE").required(true))
.arg(
Arg::with_name("bar")
.value_name("[BAR_OPTIONS]")
.short("b")
.long("bar")
.multiple(true)
.help("Invoke bar with these options"),
)
.get_matches();
When I try to pass the command "-baz=3"
to bar
like so:
./foo -b -baz=3 file.txt
or
./foo -b "-baz=3" file.txt
clap
returns this error:
error: Found argument '-b' which wasn't expected, or isn't valid in this context
How do I tunnel commands through Clap?