mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-25 14:26:58 +00:00
Add cli option to select device to control (#6)
Co-authored-by: crapStone <crapstone01@gmail.com> Reviewed-on: https://codeberg.org/crapStone/lamp/pulls/6
This commit is contained in:
parent
6f84078759
commit
620ba2bbe8
3 changed files with 31 additions and 9 deletions
15
src/main.rs
15
src/main.rs
|
@ -18,7 +18,20 @@ fn main() {
|
|||
|
||||
let (default_ctrl, ctrls) = controllers::get_controllers();
|
||||
|
||||
let p = ctrls.get(&default_ctrl).unwrap().to_owned();
|
||||
let p = match matches.value_of("controller") {
|
||||
Some(ctrl) => {
|
||||
let p = ctrls.get(ctrl);
|
||||
if p == None {
|
||||
eprintln!("no device with name '{ctrl}' found");
|
||||
eprintln!("use --list to ge a list of all available devices");
|
||||
exit(exitcode::DATAERR);
|
||||
}
|
||||
|
||||
p.unwrap().to_owned()
|
||||
}
|
||||
None => ctrls.get(&default_ctrl).unwrap().to_owned(),
|
||||
};
|
||||
|
||||
let controller: Box<dyn Controller> = match matches.value_of("ctrl_type") {
|
||||
Some("raw") => Box::new(RawController::new(p)),
|
||||
Some("lin") => Box::new(LinController::new(p)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue