From c2ec92212e1c63df0edbc6f2354f2f96d6d0894c Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Mon, 30 Nov 2026 07:33:36 +0700 Subject: [PATCH] refactor: show help when running `si` with no command --- Cargo.toml | 5 ----- crates/cli/Cargo.toml | 2 +- crates/cli/src/main.rs | 16 +++++++++++++--- crates/signed_app/Cargo.toml | 2 +- crates/signed_state/Cargo.toml | 2 +- desktop/Cargo.toml | 4 ++-- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 35cb61f..329da6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ signed_app = { path = "crates/signed_app" } nostr = { git = "https://github.com/rust-nostr/nostr", features = ["nip59", "nip49", "nip44", "os-rng"] } nostr-lmdb = { git = "https://github.com/rust-nostr/nostr" } -nostr-blossom = { git = "https://github.com/rust-nostr/nostr" } nostr-gossip-memory = { git = "https://github.com/rust-nostr/nostr" } nostr-connect = { git = "https://github.com/rust-nostr/nostr" } nostr-sdk = { git = "https://github.com/rust-nostr/nostr" } @@ -27,20 +26,16 @@ gix = { version = "0.88", default-features = false, features = ["sha1", "blockin jiff = "0.2" -smol = "2" futures = "0.3" flume = { version = "0.11.1", default-features = false, features = ["async", "select"] } rust-embed = { version = "8.5", features = ["include-exclude"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -schemars = "1" log = "0.4" anyhow = "1.0.44" webbrowser = "1.0.4" tracing-subscriber = { version = "0.3.18", features = ["fmt"] } tracing = "0.1" -errno = { version = "0.3.14", default-features = false } -instant = "0.1" [profile.release] strip = true diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index eb4f9f3..1d324f1 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -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" diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 9d2fc2d..502e04b 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -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, } #[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; } diff --git a/crates/signed_app/Cargo.toml b/crates/signed_app/Cargo.toml index c3055c1..18a317d 100644 --- a/crates/signed_app/Cargo.toml +++ b/crates/signed_app/Cargo.toml @@ -7,7 +7,7 @@ publish.workspace = true [dependencies] metadata = { path = "../metadata" } paths = { path = "../paths" } -settings = { path = "../settings" } +settings.workspace = true signed_core = { path = "../signed_core" } signed_git = { path = "../signed_git" } signed_nostr = { path = "../signed_nostr" } diff --git a/crates/signed_state/Cargo.toml b/crates/signed_state/Cargo.toml index 5828e73..5aaf6f6 100644 --- a/crates/signed_state/Cargo.toml +++ b/crates/signed_state/Cargo.toml @@ -8,7 +8,7 @@ publish.workspace = true signed_core = { path = "../signed_core" } signed_git = { path = "../signed_git" } signed_nostr = { path = "../signed_nostr" } -settings = { path = "../settings" } +settings.workspace = true paths = { path = "../paths" } utils = { path = "../utils" } diff --git a/desktop/Cargo.toml b/desktop/Cargo.toml index b6db5c3..14f8a8f 100644 --- a/desktop/Cargo.toml +++ b/desktop/Cargo.toml @@ -29,8 +29,8 @@ icons = [ [dependencies] metadata = { path = "../crates/metadata" } paths = { path = "../crates/paths" } -settings = { path = "../crates/settings" } -signed_app = { path = "../crates/signed_app" } +settings.workspace = true +signed_app.workspace = true signed_state = { path = "../crates/signed_state" } gpui.workspace = true