These are chat archives for kbknapp/clap-rs

5th
Feb 2018
Thibaut Schaeffer
@Schaeff
Feb 05 2018 11:33
Hi! Just wondering if there are ways to unit test a Clap CLI? https://github.com/kbknapp/clap-rs/blob/master/clap-test.rs looks like it does what I want, but I'm not sure it's available with Cargo?
Kevin K.
@kbknapp
Feb 05 2018 13:29
@Schaeff there is the assert_cli crate that does exactly this ;)
Thibaut Schaeffer
@Schaeff
Feb 05 2018 14:19
Thanks @kbknapp I'll give it a go!
Michael Walczyk
@mwalczyk
Feb 05 2018 19:28
hey all, what is the best way to parse an Arg with multiple values, into a tuple of integers?
basically, i have a program that takes a resolution (width and height) that i want to be able to set via commandline args. So, right now i have something like: let resolution: Vec<&str> = matches.values_of("resolution").unwrap().collect();
but the problem is, i can't figure out how to set this up with a default value (since this argument isnt required)
like, i want this to default to (128, 128), unless the user passes something in, like the above
Michael Walczyk
@mwalczyk
Feb 05 2018 19:33
for Args with only one value, i can use unwrap_or(...) like: let output_directory = matches.value_of("output_directory").unwrap_or("images");... can't figure out how to specify a default value for an Arg with multiple values