From b8dfcd0e9702c4c852114ee68634c741e0fc131c Mon Sep 17 00:00:00 2001 From: adlee-was-taken Date: Tue, 28 Apr 2026 19:16:05 -0400 Subject: [PATCH] feat(cli): clap surface for backup export/restore (handlers stubbed) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds 'relicario backup' as a subcommand wrapping export and restore. Stubs return 'not yet implemented' — handlers land in Tasks 8 and 9. The existing top-level 'relicario restore ' (un-trash) is untouched. --- crates/relicario-cli/src/main.rs | 58 ++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/crates/relicario-cli/src/main.rs b/crates/relicario-cli/src/main.rs index 7526882..9323a5b 100644 --- a/crates/relicario-cli/src/main.rs +++ b/crates/relicario-cli/src/main.rs @@ -94,6 +94,12 @@ enum Commands { action: TrashAction, }, + /// Backup operations: pack and unpack `.relbak` archives. + Backup { + #[command(subcommand)] + action: BackupAction, + }, + /// Attach a file to an item. Attach { query: String, file: PathBuf }, @@ -274,6 +280,35 @@ enum DeviceAction { Revoke { name: String }, } +#[derive(Subcommand)] +enum BackupAction { + /// Pack the local vault into a single encrypted `.relbak` file. + /// Backup passphrase is independent of the vault passphrase. + Export { + /// Output `.relbak` path. + out: PathBuf, + /// Bundle the reference JPEG into the encrypted envelope. + #[arg(long)] + include_image: bool, + /// Override the reference image path (defaults to the vault's + /// `reference.jpg` or `RELICARIO_IMAGE`). + #[arg(long)] + image: Option, + /// Skip bundling `.git/` history. + #[arg(long)] + no_history: bool, + }, + /// Unpack a `.relbak` file into a fresh vault directory. + Restore { + /// Input `.relbak` path. + input: PathBuf, + /// Target directory (must NOT already contain `.relicario/`). + /// Defaults to the current directory. + #[arg(default_value = ".")] + target: PathBuf, + }, +} + fn main() -> Result<()> { let cli = Cli::parse(); match cli.command { @@ -287,6 +322,7 @@ fn main() -> Result<()> { Commands::Restore { query } => cmd_restore(query), Commands::Purge { query } => cmd_purge(query), Commands::Trash { action } => cmd_trash(action), + Commands::Backup { action } => cmd_backup(action), Commands::Attach { query, file } => cmd_attach(query, file), Commands::Attachments { query } => cmd_attachments(query), Commands::Extract { query, aid, out } => cmd_extract(query, aid, out), @@ -1243,6 +1279,28 @@ fn cmd_trash(action: TrashAction) -> Result<()> { } } +fn cmd_backup(action: BackupAction) -> Result<()> { + match action { + BackupAction::Export { out, include_image, image, no_history } => { + cmd_backup_export(out, include_image, image, no_history) + } + BackupAction::Restore { input, target } => cmd_backup_restore(input, target), + } +} + +fn cmd_backup_export( + _out: PathBuf, + _include_image: bool, + _image: Option, + _no_history: bool, +) -> Result<()> { + anyhow::bail!("cmd_backup_export not yet implemented") +} + +fn cmd_backup_restore(_input: PathBuf, _target: PathBuf) -> Result<()> { + anyhow::bail!("cmd_backup_restore not yet implemented") +} + fn cmd_trash_empty() -> Result<()> { use relicario_core::time::now_unix;