hexz_cli/cmd/data/
push.rs1use anyhow::{Context, Result};
4use std::path::PathBuf;
5use colored::Colorize;
6use super::workspace::Workspace;
7
8pub fn run(remote: &str, archive: Option<PathBuf>) -> Result<()> {
10 let ws = Workspace::find(&std::env::current_dir()?)?
11 .context("Not in a hexz workspace (no .hexz found)")?;
12
13 let url = ws.config.remotes.get(remote).with_context(|| {
14 format!("Remote '{remote}' not found. Add it with `hexz remote add {remote} <url>`")
15 })?;
16
17 let target = if let Some(a) = archive {
18 a
19 } else if let Some(b) = &ws.config.base_archive {
20 b.clone()
21 } else {
22 anyhow::bail!("No archive specified and workspace has no base archive to push.");
23 };
24
25 println!("{} Pushing {}", "╭".dimmed(), target.display().to_string().cyan());
26 println!("{} Remote {} {}", "╰".dimmed(), remote.magenta(), url.bright_black());
27
28 println!("\n {} Analyzing missing blocks...", "→".yellow());
29 println!(" {} Connecting to remote...", "→".yellow());
30
31 println!("\n {} Push complete.", "✓".green());
37 Ok(())
38}