Default value on the command line
- In this example we set the config_file variable to the parameter passed on the command line
- or to a default value that can be any string, including the empty string.
examples/args/default-value/src/main.rs
fn main() { let argv: Vec<String> = std::env::args().collect(); let config_file = if argv.len() == 2 { &argv[1] } else { //"" "config.yaml" }; println!("'{}'", config_file); }