feat(cli): clap surface for backup export/restore (handlers stubbed)

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 <query>' (un-trash) is
untouched.
This commit is contained in:
adlee-was-taken
2026-04-28 19:16:05 -04:00
parent e02f62f961
commit b8dfcd0e97

View File

@@ -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<PathBuf>,
/// 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<PathBuf>,
_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;