Print help instead of deploying on bare `smb`
Running `smb` with no subcommand used to fall through to an implicit deploy, which exits non-zero whenever there's no config, no login, or no network. winget's installer validation launches the binary with no args and treats a non-zero exit as a failure, so the package kept failing validation. Bare invocation now prints clap help and exits 0. Deploy stays an explicit command. The two downstream None arms are now unreachable. Co-Authored-By: siGit Code v1.6.7-acp <noreply@sigit.si>
Seto Elkahfi committed
Oct 11, 2026 at 20:34 UTC
972bd70910254a106fd81a9de3296b7b5fc736e3
1 file changed
+15
-4
crates/cli/src/main.rs
+15
-4
@@ -1,6 +1,6 @@
1
use {
2
anyhow::{anyhow, Result},
3
- clap::Parser,
3
+ clap::{CommandFactory, Parser},
4
console::style,
5
smbcloud_cli::{
6
account::{login::process_login, logout::process_logout, me::process_me, process_account},
@@ -172,6 +172,17 @@ async fn run(cli: Cli) -> Result<CommandResult> {
172
setup_logging(cli.environment, None)?;
173
}
174
175
+ // Bare `smb` with no subcommand prints help and exits cleanly. Deploy is a
176
+ // deliberate action, so we don't want to run it implicitly — and winget's
177
+ // installer validation launches the exe with no arguments and treats a
178
+ // non-zero exit as a failure, which an implicit deploy (no config, no
179
+ // login, no network) would always trigger.
180
+ if cli.command.is_none() {
181
+ Cli::command().print_help()?;
182
+ println!();
183
+ std::process::exit(0);
184
+ }
185
+
186
// Check if the command requires internet connection
187
let needs_internet = match &cli.command {
188
Some(Commands::Me {})
@@ -183,10 +194,10 @@ async fn run(cli: Cli) -> Result<CommandResult> {
194
| Some(Commands::Auth { .. })
195
| Some(Commands::Project { .. })
196
| Some(Commands::Tenant { .. })
186
- | Some(Commands::Migrate {})
187
- | None => true,
197
+ | Some(Commands::Migrate {}) => true,
198
Some(Commands::ControlKit { .. }) => false,
199
Some(Commands::Init {}) => true,
200
+ None => unreachable!("handled above: bare invocation prints help and exits"),
201
};
202
203
// Check internet connectivity for commands that need it
@@ -209,6 +220,6 @@ async fn run(cli: Cli) -> Result<CommandResult> {
220
Some(Commands::Tenant { command }) => process_tenant(cli.environment, command).await,
221
Some(Commands::ControlKit { command }) => process_controlkit(command).await,
222
Some(Commands::Migrate {}) => process_migrate(cli.environment).await,
212
- None => process_deploy(cli.environment, None).await,
223
+ None => unreachable!("handled above: bare invocation prints help and exits"),
224
}
225
}