pub async fn install_resources_with_dynamic_progress(
lockfile: &LockFile,
manifest: &Manifest,
project_dir: &Path,
cache: &Cache,
force_refresh: bool,
max_concurrency: Option<usize>,
progress_bar: Option<Arc<ProgressBar>>,
) -> Result<usize>Expand description
Install resources with real-time dynamic progress management.
This function provides sophisticated parallel resource installation with
live progress tracking that shows individual dependency states in real-time.
It uses a ProgressBar to display progress of dependencies
are currently being processed, completed, or experiencing issues.
§Arguments
lockfile- Lockfile containing all resources to installmanifest- Project manifest providing configuration and target directoriesproject_dir- Root directory where resources will be installedcache- Cache instance for Git repository and worktree managementforce_refresh- Whether to force refresh of cached repositoriesmax_concurrency- Optional limit on concurrent operations (None= unlimited)progress_bar- Optional dynamic progress bar for real-time updates
§Dynamic Progress Features
When a ProgressBar is provided, the installation displays:
- Real-time list of dependencies being processed concurrently
- Live updates as dependencies start, progress, and complete
- Clean terminal output with automatic clearing when finished
- Graceful handling of errors with preserved context
§Progress Flow
- Initialization: Progress manager starts with total dependency count
- Pre-warming: Cache prepares Git worktrees for parallel access
- Parallel Processing: Dependencies install concurrently with live updates
- Completion: Progress display clears, leaving clean final state
§Examples
use agpm_cli::installer::install_resources_with_dynamic_progress;
use agpm_cli::utils::progress::ProgressBar;
use agpm_cli::lockfile::LockFile;
use agpm_cli::manifest::Manifest;
use agpm_cli::cache::Cache;
use std::sync::Arc;
use std::path::Path;
let lockfile = LockFile::load(Path::new("agpm.lock"))?;
let manifest = Manifest::load(Path::new("agpm.toml"))?;
let cache = Cache::new()?;
// Create dynamic progress manager
let progress_bar = Arc::new(ProgressBar::new(100));
let count = install_resources_with_dynamic_progress(
&lockfile,
&manifest,
Path::new("."),
&cache,
false, // No force refresh
Some(10), // Max 10 concurrent operations
Some(progress_bar) // Dynamic progress display
).await?;
println!("Successfully installed {} resources", count);§Performance Optimizations
The function includes several performance enhancements:
- Worktree pre-warming: All needed Git worktrees created upfront
- Parallel processing: Configurable concurrency for optimal resource usage
- Progress batching: Updates are batched to reduce terminal overhead
- Efficient cleanup: Worktrees left for reuse rather than immediate cleanup
§Returns
Returns the total number of resources that were actually installed. This count only includes resources with new or updated content, not resources that already existed and were unchanged.
§Errors
Returns an error if any resource installation fails. The error includes detailed information about all failed installations. The progress manager is automatically cleaned up even if errors occur.