diff --git a/src/main.rs b/src/main.rs index 42e8be7..0224e6a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,7 @@ use log::{ use tokio_serial; #[derive(Subcommand, Clone)] +#[command(arg_required_else_help = true)] enum DeviceCommands { /// Request current state State, @@ -52,6 +53,7 @@ impl Default for DeviceCommands { } #[derive(Subcommand, Clone)] +#[command(arg_required_else_help = true)] enum Commands { /// List available serial devices ListDevices, @@ -68,7 +70,7 @@ enum Commands { } #[derive(Parser)] -#[command(version, about, long_about = None)] +#[command(version, about, long_about = None, arg_required_else_help = true)] struct Cli { #[command(subcommand)] command: Option, @@ -112,10 +114,7 @@ async fn main() -> Result<()>{ let cli = Cli::parse(); - let command: Commands = match &cli.command { - Some(command) => command.clone(), - None => Commands::ListDevices, - }; + let command = &cli.command.context("No command provided")?.clone(); match &command { Commands::ListDevices => {