pumopm/src/main.rs

48 lines
996 B
Rust
Raw Normal View History

2020-08-10 16:26:41 +00:00
mod battery_state;
// use battery_state::*;
use battery_state::{BatteryState, VerbosityLevel};
use clap::Clap;
#[derive(Clap)]
#[clap(
2020-08-12 21:29:55 +00:00
version = "0.1.1",
author = "Lucien Cartier-Tilet <lucien@phundrak.com>"
)]
struct Opts {
#[clap(short, long, default_value = "25")]
low: u8,
#[clap(short = "L", long, default_value = "15")]
very_low: u8,
#[clap(short, long, default_value = "10")]
critical: u8,
#[clap(short, long = "refresh-rate", default_value = "5")]
refresh_rate: u64,
#[clap(short, long, parse(from_occurrences))]
verbose: i32,
}
2020-08-10 16:26:41 +00:00
fn main() {
let opts: Opts = Opts::parse();
let mut battery = BatteryState::new(
opts.low,
opts.very_low,
opts.critical,
opts.refresh_rate,
match opts.verbose {
0 => VerbosityLevel::None,
1 => VerbosityLevel::Some,
_ => VerbosityLevel::Lots,
},
)
.unwrap();
2020-08-10 16:26:41 +00:00
loop {
battery.update();
}
}