2021-02-11 15:05:10 +01:00
|
|
|
#[macro_use]
|
|
|
|
|
extern crate clap;
|
|
|
|
|
|
2021-02-11 22:09:29 +01:00
|
|
|
mod cfg_reader;
|
2021-02-25 21:59:09 +01:00
|
|
|
mod pulse_counter;
|
2021-02-11 22:09:29 +01:00
|
|
|
|
2021-02-11 15:05:10 +01:00
|
|
|
const APP_VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
|
|
|
|
const DEFAULT_CONFIG_FILE_NAME: &str = "/etc/s0_logger.cfg";
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
let cli_args = clap_app!(s0_meter =>
|
|
|
|
|
(version: APP_VERSION)
|
|
|
|
|
(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 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 config_file_name = cli_args
|
|
|
|
|
.value_of("config")
|
|
|
|
|
.unwrap_or(DEFAULT_CONFIG_FILE_NAME);
|
|
|
|
|
println!("Read the config from file '{}'", config_file_name);
|
|
|
|
|
|
|
|
|
|
}
|