improvements

This commit is contained in:
crapStone 2022-07-16 01:01:48 +02:00
parent 114e567826
commit 3a8ebca75e
No known key found for this signature in database
GPG key ID: 4CAA9E39EEDEB1F0
4 changed files with 59 additions and 56 deletions

View file

@ -23,22 +23,22 @@ fn main() {
Some("raw") => Box::new(RawController::new(p)),
Some("lin") => Box::new(LinController::new(p)),
Some("log") => Box::new(LogController::new(p)),
Some(_) | None => panic!("{}", ERROR_MSG),
Some(_) | None => panic!("{ERROR_MSG}"),
};
if matches.is_present("list") {
for ctrl in ctrls.keys() {
println!("{}", ctrl);
println!("{ctrl}");
}
exit(exitcode::OK);
} else if let Some(value) = matches.value_of("set") {
let new_value = value.parse::<i32>().unwrap();
let new_value = value.parse::<u32>().unwrap();
controller.set_brightness(new_value);
} else if let Some(value) = matches.value_of("inc") {
let new_value = controller.get_brightness() + value.parse::<i32>().unwrap();
let new_value = controller.get_brightness() + value.parse::<u32>().unwrap();
controller.set_brightness(new_value.min(controller.get_max_brightness()));
} else if let Some(value) = matches.value_of("dec") {
let new_value = controller.get_brightness() - value.parse::<i32>().unwrap();
let new_value = controller.get_brightness() - value.parse::<u32>().unwrap();
controller.set_brightness(new_value.max(0));
} else if matches.is_present("get") {
println!("{}", controller.get_brightness());