refactor: show help when running si with no command
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s
Rust / build (macos-latest, stable) (pull_request) Canceled after 0s
Rust / build (windows-latest, stable) (pull_request) Canceled after 0s
Rust / build (ubuntu-latest, stable) (pull_request) Canceled after 0s

This commit is contained in:
2026-11-30 07:33:36 +07:00
parent df1f232aae
commit c2ec92212e
6 changed files with 18 additions and 13 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ path = "src/main.rs"
signed_core = { path = "../signed_core" }
signed_git = { path = "../signed_git" }
signed_state = { path = "../signed_state" }
settings = { path = "../settings" }
settings.workspace = true
paths = { path = "../paths" }
rpassword = "7"
+13 -3
View File
@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
use std::process::Stdio;
use anyhow::{Context as _, bail};
use clap::{Args, Parser, Subcommand};
use clap::{Args, CommandFactory as _, Parser, Subcommand};
use gpui::{App, AsyncApp, Entity, Subscription};
use nostr::nips::nip19::Nip19Coordinate;
use nostr::prelude::{PublicKey, RelayUrl, ToBech32 as _};
@@ -18,7 +18,7 @@ use signed_state::{Backend, BackendEvent, CheckoutsStore};
#[command(name = "si", version, about)]
struct Cli {
#[command(subcommand)]
command: Command,
command: Option<Command>,
}
#[derive(Subcommand)]
@@ -98,12 +98,22 @@ fn main() {
let cli = Cli::parse();
// A bare `si` lists the commands instead of failing.
let Some(command) = cli.command else {
if let Err(error) = Cli::command().print_help() {
eprintln!("error: failed to write help: {error}");
std::process::exit(1);
}
return;
};
gpui_platform::headless().run(move |cx| {
// The callback runs before the platform's run loop, so the command awaits inside a foreground task.
cx.spawn(async move |cx| {
let mut code = 0;
if let Err(error) = run(cli.command, cx).await {
if let Err(error) = run(command, cx).await {
eprintln!("error: {error:#}");
code = 1;
}