These are chat archives for kbknapp/clap-rs

26th
Nov 2018
loothood
@loothood
Nov 26 2018 15:48

Hi all
could you help me please?
I want to get path as arg.
So, input line maybe:

./myprogram "."
./myprogram ".*"
./myprogram file1.txt
./myprogram file1.txt file2.txt file3.txt ...

how can I get variable number of parameters?
I wrote:

 let args = App::new("Checker")
        .version("0.1.0")
        .author("Me")
        .about("checker")
        .arg(Arg::with_name("path").
                    required(true).
                    takes_value(true).
                    index( 1)
                    .help("help page")
        ).get_matches();

So, that covers first three cases. But in case ./myprogram file1.txt file2.txt file3.txt ..., I dont know what to do

Matthew Klein
@mklein994
Nov 26 2018 21:08
Arg::possible_values() takes a &'a [&'b str]. I have a Vec<String>. How would I go about converting that? The arg_enum! macro doesn't quite do what I want, since it doesn't convert the casing as I would like.