Don't panic when the config file couldn#t be read + disable cli arg "-v".

This commit is contained in:
Harald Kube 2021-03-01 00:52:00 +01:00
parent f50ac52cc1
commit 26b6cf5e6c

View file

@ -57,19 +57,19 @@ impl rest_api::DataProvider for PulseDataProvider {
fn main() {
let cli_args = clap_app!(s0_meter =>
(version: APP_VERSION)
(author: "Harald Kube <harald.kube@gmx.de")
(author: "Harald Kube <harald.kube@gmx.de>")
(about: "Listen for S0 pulses at the given GPIO pins")
(@arg v: -v ... "Set the verbosity level (up to -vvv)")
// (@arg v: -v ... "Set the verbosity level (up to -vvv)")
(@arg config: -c --config +takes_value "The name of the config file (default: /etc/s0_logger.cfg)")
).get_matches();
let log_level = cli_args.occurrences_of("v");
match log_level {
0 => println!("No logging"),
1 => println!("A little logging"),
2 => println!("A little more logging"),
_ => println!("A lot logging"),
};
// let log_level = cli_args.occurrences_of("v");
// match log_level {
// 0 => println!("No logging"),
// 1 => println!("A little logging"),
// 2 => println!("A little more logging"),
// _ => println!("A lot logging"),
// };
let config_file_name = cli_args
.value_of("config")
@ -91,10 +91,11 @@ fn main() {
}
Err(err_msg) => {
// TODO Log
panic!(
println!(
"Error while parsing config file {}: {}",
config_file_name, err_msg
);
std::process::exit(1);
}
};