cli: add a progress spinner to pakker fork init

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Id40f83862483f20e569cbd27d38143f96a6a6964
This commit is contained in:
raf 2026-05-01 18:56:51 +03:00
commit 754927c55a
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -3,8 +3,11 @@ use std::{
fs,
io::Write,
path::Path,
time::Duration,
};
use indicatif::{ProgressBar, ProgressStyle};
use crate::{
cli::ForkArgs,
error::PakkerError,
@ -270,11 +273,19 @@ fn execute_init(
// re-downloading objects
let parent_path = Path::new(&parent_path_str);
println!(
let spinner = ProgressBar::new_spinner();
spinner.set_style(
ProgressStyle::default_spinner()
.template("{spinner:.green} {msg}")
.expect("spinner template is valid"),
);
spinner.enable_steady_tick(Duration::from_millis(80));
spinner.set_message(format!(
"Cloning parent repository from local path {}...",
path.display()
);
));
git::clone_repository(&fp, parent_path, &resolved_ref, None)?;
spinner.finish_and_clear();
// Ensure the cloned repo's origin is set to the upstream URL (not the local
// path)
@ -317,11 +328,18 @@ fn execute_init(
}
}
println!("Cloning parent repository...");
println!(" URL: {url}");
println!(" Ref: {resolved_ref}");
let spinner = ProgressBar::new_spinner();
spinner.set_style(
ProgressStyle::default_spinner()
.template("{spinner:.green} {msg}")
.expect("spinner template is valid"),
);
spinner.enable_steady_tick(Duration::from_millis(80));
spinner.set_message(format!(
"Cloning parent repository: {url} ({resolved_ref})"
));
git::clone_repository(&url, parent_path, &resolved_ref, None)?;
spinner.finish_and_clear();
}
let commit_sha = git::get_commit_sha(parent_path, &resolved_ref)?;