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, fs,
io::Write, io::Write,
path::Path, path::Path,
time::Duration,
}; };
use indicatif::{ProgressBar, ProgressStyle};
use crate::{ use crate::{
cli::ForkArgs, cli::ForkArgs,
error::PakkerError, error::PakkerError,
@ -270,11 +273,19 @@ fn execute_init(
// re-downloading objects // re-downloading objects
let parent_path = Path::new(&parent_path_str); 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 {}...", "Cloning parent repository from local path {}...",
path.display() path.display()
); ));
git::clone_repository(&fp, parent_path, &resolved_ref, None)?; 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 // Ensure the cloned repo's origin is set to the upstream URL (not the local
// path) // path)
@ -317,11 +328,18 @@ fn execute_init(
} }
} }
println!("Cloning parent repository..."); let spinner = ProgressBar::new_spinner();
println!(" URL: {url}"); spinner.set_style(
println!(" Ref: {resolved_ref}"); 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)?; git::clone_repository(&url, parent_path, &resolved_ref, None)?;
spinner.finish_and_clear();
} }
let commit_sha = git::get_commit_sha(parent_path, &resolved_ref)?; let commit_sha = git::get_commit_sha(parent_path, &resolved_ref)?;