feat: add si command line interface #37

Merged
reya merged 7 commits from feat/cli into master 2026-11-30 00:34:45 +00:00
6 changed files with 18 additions and 13 deletions
Showing only changes of commit c2ec92212e - Show all commits
-5
View File
@@ -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 = { git = "https://github.com/rust-nostr/nostr", features = ["nip59", "nip49", "nip44", "os-rng"] }
nostr-lmdb = { git = "https://github.com/rust-nostr/nostr" } 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-gossip-memory = { git = "https://github.com/rust-nostr/nostr" }
nostr-connect = { 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" } 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" jiff = "0.2"
smol = "2"
futures = "0.3" futures = "0.3"
flume = { version = "0.11.1", default-features = false, features = ["async", "select"] } flume = { version = "0.11.1", default-features = false, features = ["async", "select"] }
rust-embed = { version = "8.5", features = ["include-exclude"] } rust-embed = { version = "8.5", features = ["include-exclude"] }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
schemars = "1"
log = "0.4" log = "0.4"
anyhow = "1.0.44" anyhow = "1.0.44"
webbrowser = "1.0.4" webbrowser = "1.0.4"
tracing-subscriber = { version = "0.3.18", features = ["fmt"] } tracing-subscriber = { version = "0.3.18", features = ["fmt"] }
tracing = "0.1" tracing = "0.1"
errno = { version = "0.3.14", default-features = false }
instant = "0.1"
[profile.release] [profile.release]
strip = true strip = true
+1 -1
View File
@@ -12,7 +12,7 @@ path = "src/main.rs"
signed_core = { path = "../signed_core" } signed_core = { path = "../signed_core" }
signed_git = { path = "../signed_git" } signed_git = { path = "../signed_git" }
signed_state = { path = "../signed_state" } signed_state = { path = "../signed_state" }
settings = { path = "../settings" } settings.workspace = true
paths = { path = "../paths" } paths = { path = "../paths" }
rpassword = "7" rpassword = "7"
+13 -3
View File
@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
use std::process::Stdio; use std::process::Stdio;
use anyhow::{Context as _, bail}; use anyhow::{Context as _, bail};
use clap::{Args, Parser, Subcommand}; use clap::{Args, CommandFactory as _, Parser, Subcommand};
use gpui::{App, AsyncApp, Entity, Subscription}; use gpui::{App, AsyncApp, Entity, Subscription};
use nostr::nips::nip19::Nip19Coordinate; use nostr::nips::nip19::Nip19Coordinate;
use nostr::prelude::{PublicKey, RelayUrl, ToBech32 as _}; use nostr::prelude::{PublicKey, RelayUrl, ToBech32 as _};
@@ -18,7 +18,7 @@ use signed_state::{Backend, BackendEvent, CheckoutsStore};
#[command(name = "si", version, about)] #[command(name = "si", version, about)]
struct Cli { struct Cli {
#[command(subcommand)] #[command(subcommand)]
command: Command, command: Option<Command>,
} }
#[derive(Subcommand)] #[derive(Subcommand)]
@@ -98,12 +98,22 @@ fn main() {
let cli = Cli::parse(); 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| { gpui_platform::headless().run(move |cx| {
// The callback runs before the platform's run loop, so the command awaits inside a foreground task. // The callback runs before the platform's run loop, so the command awaits inside a foreground task.
cx.spawn(async move |cx| { cx.spawn(async move |cx| {
let mut code = 0; let mut code = 0;
if let Err(error) = run(cli.command, cx).await { if let Err(error) = run(command, cx).await {
eprintln!("error: {error:#}"); eprintln!("error: {error:#}");
code = 1; code = 1;
} }
+1 -1
View File
@@ -7,7 +7,7 @@ publish.workspace = true
[dependencies] [dependencies]
metadata = { path = "../metadata" } metadata = { path = "../metadata" }
paths = { path = "../paths" } paths = { path = "../paths" }
settings = { path = "../settings" } settings.workspace = true
signed_core = { path = "../signed_core" } signed_core = { path = "../signed_core" }
signed_git = { path = "../signed_git" } signed_git = { path = "../signed_git" }
signed_nostr = { path = "../signed_nostr" } signed_nostr = { path = "../signed_nostr" }
+1 -1
View File
@@ -8,7 +8,7 @@ publish.workspace = true
signed_core = { path = "../signed_core" } signed_core = { path = "../signed_core" }
signed_git = { path = "../signed_git" } signed_git = { path = "../signed_git" }
signed_nostr = { path = "../signed_nostr" } signed_nostr = { path = "../signed_nostr" }
settings = { path = "../settings" } settings.workspace = true
paths = { path = "../paths" } paths = { path = "../paths" }
utils = { path = "../utils" } utils = { path = "../utils" }
+2 -2
View File
@@ -29,8 +29,8 @@ icons = [
[dependencies] [dependencies]
metadata = { path = "../crates/metadata" } metadata = { path = "../crates/metadata" }
paths = { path = "../crates/paths" } paths = { path = "../crates/paths" }
settings = { path = "../crates/settings" } settings.workspace = true
signed_app = { path = "../crates/signed_app" } signed_app.workspace = true
signed_state = { path = "../crates/signed_state" } signed_state = { path = "../crates/signed_state" }
gpui.workspace = true gpui.workspace = true