| // SPDX-FileCopyrightText: 2020 Robin Krahl <robin.krahl@ireas.org> |
| // SPDX-License-Identifier: CC0-1.0 |
| use structopt::StructOpt; |
| #[derive(Debug, Default, Deserialize, Merge, StructOpt)] |
| #[structopt(short, long)] |
| #[merge(strategy = merge::bool::overwrite_false)] |
| fn get_config() -> Option<Args> { |
| let path: &std::path::Path = "args.toml".as_ref(); |
| let s = std::fs::read_to_string(path).expect("Could not read configuration file"); |
| Some(toml::from_str(&s).expect("Could not parse configuration")) |
| .expect("Could not read environment variables") |
| let mut args = Args::from_args(); |
| if let Some(config) = get_config() { |