make SET stub + move elements into system wrapper

This commit is contained in:
sigil-03 2025-04-06 14:34:15 -06:00
parent fd120be85e
commit 987150c9b6
6 changed files with 108 additions and 65 deletions

View file

@ -1,21 +1,31 @@
use clap::{Parser, Subcommand};
use monitor::Monitor;
mod control;
mod monitor;
mod system;
mod tasmota;
mod types;
#[derive(Subcommand)]
pub enum Commands {
Monitor,
#[command(subcommand)]
Set(types::PowerState),
}
impl Commands {
pub async fn execute(self, config_file: &str) {
let handle = match self {
Self::Monitor => {
let m = Monitor::new_from_file(config_file).unwrap();
let s = system::System::new_from_file(config_file).unwrap();
tokio::spawn(async move {
m.get_power().await.unwrap();
s.get_power().await.unwrap();
})
}
Self::Set(state) => {
// let c = Controller::new_from_file(config_file).unwrap();
tokio::spawn(async move {
println!("SET");
})
}
};