pub async fn install_resource_with_progress(
entry: &LockedResource,
resource_dir: &str,
context: &InstallContext<'_>,
pb: &ProgressBar,
) -> Result<(bool, String, Option<String>, AppliedPatches, Option<u64>)>Expand description
Install a single resource with progress bar updates for user feedback.
This function wraps install_resource with progress bar integration to provide
real-time feedback during resource installation. It updates the progress bar
message before delegating to the core installation logic.
§Arguments
entry- The locked resource containing installation metadataproject_dir- Root project directory for installation targetresource_dir- Subdirectory name for this resource type (e.g., “agents”)cache- Cache instance for Git repository and worktree managementforce_refresh- Whether to force refresh of cached repositoriespb- Progress bar to update with installation status
§Returns
Returns a tuple of:
bool: Whether the resource was actually installed (truefor new/updated,falsefor unchanged)String: SHA-256 checksum of the installed file contentOption<String>: SHA-256 checksum of the template rendering inputs, or None for non-templated resourcesAppliedPatches: Information about any patches that were applied during installation
§Progress Integration
The function automatically sets the progress bar message to indicate which resource is currently being installed. This provides users with real-time feedback about installation progress.
§Examples
use agpm_cli::installer::{install_resource_with_progress, InstallContext};
use agpm_cli::lockfile::{LockedResource, LockedResourceBuilder};
use agpm_cli::cache::Cache;
use agpm_cli::core::ResourceType;
use indicatif::ProgressBar;
use std::path::Path;
let cache = Cache::new()?;
let pb = ProgressBar::new(1);
let entry = LockedResourceBuilder::new(
"example-agent".to_string(),
"agents/example.md".to_string(),
"sha256:...".to_string(),
".claude/agents/example.md".to_string(),
ResourceType::Agent,
)
.source(Some("community".to_string()))
.url(Some("https://github.com/example/repo.git".to_string()))
.version(Some("v1.0.0".to_string()))
.resolved_commit(Some("abc123".to_string()))
.tool(Some("claude-code".to_string()))
.build();
let context = InstallContext::builder(Path::new("."), &cache).build();
let (installed, checksum, _old_checksum, _patches, _token_count) = install_resource_with_progress(
&entry,
"agents",
&context,
&pb
).await?;
pb.inc(1);§Errors
Returns the same errors as install_resource, including:
- Repository access failures
- File system operation errors
- Invalid markdown content
- Git worktree creation failures