From dbdb3f6ab091ca3b216d96b420753390e19ee60d Mon Sep 17 00:00:00 2001 From: adlee-was-taken Date: Sat, 20 Jun 2026 12:33:07 -0400 Subject: [PATCH] refactor(cli/org): align org init main.rs wiring to OrgCommands + global --dir (B14-shaped) + assert org-init trailer --- crates/relicario-cli/src/main.rs | 29 ++++++++++++------- .../relicario-cli/tests/org_init_signing.rs | 8 +++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/crates/relicario-cli/src/main.rs b/crates/relicario-cli/src/main.rs index 2a9f80c..639c5be 100644 --- a/crates/relicario-cli/src/main.rs +++ b/crates/relicario-cli/src/main.rs @@ -208,10 +208,13 @@ enum Commands { cmd: RecoveryQrCmd, }, - /// Multi-user org vault operations. + /// Manage a multi-user org vault. Org { + /// Path to the org vault directory (overrides RELICARIO_ORG_DIR). + #[arg(long, global = true)] + dir: Option, #[command(subcommand)] - action: OrgAction, + subcommand: OrgCommands, }, } @@ -429,16 +432,13 @@ pub(crate) enum RecoveryQrCmd { } #[derive(clap::Subcommand)] -pub(crate) enum OrgAction { - /// Initialize a new org vault (creates dir structure, git repo, signed commit). +pub(crate) enum OrgCommands { + /// Create a new org vault. Init { - /// Directory to create the org vault in. - #[arg(long)] - dir: PathBuf, - /// Human-readable display name for the org. #[arg(long)] name: String, }, + // Admin + item subcommands are added by later tasks (B10-B14). } fn main() -> Result<()> { @@ -475,9 +475,16 @@ fn main() -> Result<()> { Commands::Rate { passphrase } => commands::rate::cmd_rate(passphrase), Commands::Device { action } => commands::device::cmd_device(action), Commands::RecoveryQr { cmd } => commands::recovery_qr::cmd_recovery_qr(cmd), - Commands::Org { action } => match action { - OrgAction::Init { dir, name } => commands::org::run_init(&dir, &name), - }, + Commands::Org { dir, subcommand } => { + let dir_path = dir.as_deref(); + match subcommand { + OrgCommands::Init { name } => { + let d = crate::org_session::org_dir(dir_path)?; + commands::org::run_init(&d, &name)?; + Ok(()) + } + } + } } } diff --git a/crates/relicario-cli/tests/org_init_signing.rs b/crates/relicario-cli/tests/org_init_signing.rs index 981d623..01a6926 100644 --- a/crates/relicario-cli/tests/org_init_signing.rs +++ b/crates/relicario-cli/tests/org_init_signing.rs @@ -134,4 +134,12 @@ fn org_init_produces_a_signed_initial_commit() { String::from_utf8_lossy(&verify.stdout), String::from_utf8_lossy(&verify.stderr) ); + + // The commit body must carry the org-init action trailer. + let log_out = git(org.path(), &["log", "-1", "--format=%B"]); + let commit_body = String::from_utf8_lossy(&log_out.stdout); + assert!( + commit_body.contains("Relicario-Action: org-init"), + "HEAD commit body must contain 'Relicario-Action: org-init' trailer:\n{commit_body}" + ); }