From 161747f5c4317837c08cfeb330c778544345ff9b Mon Sep 17 00:00:00 2001 From: Chapman Pendery Date: Mon, 29 Jun 2026 13:44:03 -0700 Subject: [PATCH] fix: exit 0 on help for winget Signed-off-by: Chapman Pendery --- src/cli.rs | 2 +- src/main.rs | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 5905c06..c3e096c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -20,7 +20,7 @@ pub struct Cli { pub verbose: bool, #[command(subcommand)] - pub command: Command, + pub command: Option, } #[derive(Subcommand)] diff --git a/src/main.rs b/src/main.rs index baa372b..8626f9b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ mod trace; use std::path::Path; use std::time::{Duration, Instant}; -use clap::Parser; +use clap::{CommandFactory, Parser}; use cli::{Cli, Command, DaemonCmd, ExpectCmd, GetArg, MouseCmd, WaitCmd}; use protocol::{GetField, MouseAction, Request, Response}; @@ -27,7 +27,12 @@ fn main() { let cli = Cli::parse(); let session = config::session_name_from_env(cli.session.clone()); - let code = match cli.command { + let Some(command) = cli.command else { + let _ = Cli::command().print_help(); + std::process::exit(0); + }; + + let code = match command { Command::InternalDaemon => { if let Err(e) = daemon::run(session, cli.verbose) { eprintln!("daemon error: {e}");