workspacer-cli 0.1.2

A versatile command-line interface for Rust workspace management, providing comprehensive controls for crate analysis, import formatting, cleanup, dependency checks, and more.
Documentation
// ---------------- [ File: workspacer-cli/src/get_lock_versions.rs ]
crate::ix!();

/// This function handles the `lock-versions` logic:
pub async fn get_lock_versions_flow(
    workspace_path: Option<PathBuf>,
    skip_git_check: bool,
) -> Result<(), WorkspaceError> 
{
    // We can re-use your run_with_workspace(...) helper if you want to
    // ensure we have a valid workspace, do Git checks, etc.
    run_with_workspace(workspace_path, skip_git_check, |ws| {
        Box::pin(async move {
            let root_dir = ws.as_ref();  // the workspace root path

            // Now call our library code
            let lock_map = build_lock_versions(&root_dir)
                .await
                .map_err(|crate_err| {
                    error!("Failed to read or parse Cargo.lock: {:?}", crate_err);
                    // Convert `CrateError` => `WorkspaceError`
                    WorkspaceError::CrateError(crate_err)
                })?;

            // Print the results in some human-friendly way:
            info!("Lockfile contains {} distinct crates:", lock_map.len());
            for (crate_name, versions) in &lock_map {
                debug!("   - {} => versions: {:?}", crate_name, versions);
                // or do a more polished print:
                println!("{} => {:?}", crate_name, versions);
            }

            Ok(())
        })
    }).await
}