Display help on missing args

This commit is contained in:
clerie 2024-12-25 15:48:57 +01:00
parent 6fd28effe5
commit 43c1de727a

View File

@ -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<Commands>,
@ -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 => {