diff --git a/src/args.rs b/src/args.rs index e89311d..180fa30 100644 --- a/src/args.rs +++ b/src/args.rs @@ -14,9 +14,11 @@ pub enum Commands { /// List all lights List, /// Inspect a light - Inspect, + Inspect { id: String }, /// Toggle a light Toggle { id: String, state: Option }, + /// Get a token + Auth, } #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] diff --git a/src/main.rs b/src/main.rs index cad87b3..4e793b9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,23 +5,31 @@ mod config; use crate::args::ToggleState; use clap::Parser; -use eyre::Result; +use eyre::{eyre, Result}; #[tokio::main] async fn main() -> Result<()> { let args = args::Args::parse(); let config = config::resolve().await?; - match &args.command { + let res = match &args.command { args::Commands::Toggle { id, state } => { - commands::toggle::exec(config, id, state).await?; + commands::toggle::exec(config, id, state).await } args::Commands::List => { - commands::list::exec(config).await?; + commands::list::exec(config).await } - args::Commands::Inspect => { - panic!("Not implemented"); + args::Commands::Inspect { id } => { + commands::inspect::exec(config, id).await } + args::Commands::Auth => { + Err(eyre!("Not yet implemented")) + } + }; + + if let Err(e) = res { + println!("⛔️ {}", e.to_string()); + std::process::exit(1); } Ok(())