Verified Commit e56f3996 authored by Maxime Buquet's avatar Maxime Buquet
Browse files

config example: add support for other arguments


Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <pep@bouah.net>
parent 41157be1
...@@ -84,15 +84,26 @@ pub fn get_config(matches: ArgMatches) -> Result<Config, Error> { ...@@ -84,15 +84,26 @@ pub fn get_config(matches: ArgMatches) -> Result<Config, Error> {
}; };
let config_str = read_file(config_path)?; let config_str = read_file(config_path)?;
let config: Config = toml::from_str(config_str.as_str())?; let mut config: Config = toml::from_str(config_str.as_str())?;
match matches.value_of("http_user") {
Some(user) => config.http_user = String::from(user),
_ => (),
}
match matches.value_of("http_password") {
Some(passwd) => config.http_password = String::from(passwd),
_ => (),
}
Ok(config) Ok(config)
} }
fn main() { fn main() {
let matches = clap_app!(@app (app_from_crate!()) let matches = clap_app!(@app (app_from_crate!())
(@arg config: -c --config +takes_value "Config file path") (@arg config: -c --config +takes_value "Config file path")
(@arg user: -u --user +takes_value +required "HTTP Basic Auth user") (@arg http_user: -u --http_user +takes_value +required "HTTP Basic Auth user")
(@arg password: -p --password +takes_value +required "HTTP Basic Auth password") (@arg http_password: -p --http_password +takes_value +required "HTTP Basic Auth password")
) )
.get_matches(); .get_matches();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment