refactor(cli/org): align org init main.rs wiring to OrgCommands + global --dir (B14-shaped) + assert org-init trailer
This commit is contained in:
@@ -208,10 +208,13 @@ enum Commands {
|
|||||||
cmd: RecoveryQrCmd,
|
cmd: RecoveryQrCmd,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Multi-user org vault operations.
|
/// Manage a multi-user org vault.
|
||||||
Org {
|
Org {
|
||||||
|
/// Path to the org vault directory (overrides RELICARIO_ORG_DIR).
|
||||||
|
#[arg(long, global = true)]
|
||||||
|
dir: Option<PathBuf>,
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
action: OrgAction,
|
subcommand: OrgCommands,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,16 +432,13 @@ pub(crate) enum RecoveryQrCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::Subcommand)]
|
#[derive(clap::Subcommand)]
|
||||||
pub(crate) enum OrgAction {
|
pub(crate) enum OrgCommands {
|
||||||
/// Initialize a new org vault (creates dir structure, git repo, signed commit).
|
/// Create a new org vault.
|
||||||
Init {
|
Init {
|
||||||
/// Directory to create the org vault in.
|
|
||||||
#[arg(long)]
|
|
||||||
dir: PathBuf,
|
|
||||||
/// Human-readable display name for the org.
|
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
name: String,
|
name: String,
|
||||||
},
|
},
|
||||||
|
// Admin + item subcommands are added by later tasks (B10-B14).
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
@@ -475,9 +475,16 @@ fn main() -> Result<()> {
|
|||||||
Commands::Rate { passphrase } => commands::rate::cmd_rate(passphrase),
|
Commands::Rate { passphrase } => commands::rate::cmd_rate(passphrase),
|
||||||
Commands::Device { action } => commands::device::cmd_device(action),
|
Commands::Device { action } => commands::device::cmd_device(action),
|
||||||
Commands::RecoveryQr { cmd } => commands::recovery_qr::cmd_recovery_qr(cmd),
|
Commands::RecoveryQr { cmd } => commands::recovery_qr::cmd_recovery_qr(cmd),
|
||||||
Commands::Org { action } => match action {
|
Commands::Org { dir, subcommand } => {
|
||||||
OrgAction::Init { dir, name } => commands::org::run_init(&dir, &name),
|
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(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,4 +134,12 @@ fn org_init_produces_a_signed_initial_commit() {
|
|||||||
String::from_utf8_lossy(&verify.stdout),
|
String::from_utf8_lossy(&verify.stdout),
|
||||||
String::from_utf8_lossy(&verify.stderr)
|
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}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user