handle_legacy_format_migration

Function handle_legacy_format_migration 

Source
pub async fn handle_legacy_format_migration(
    project_dir: &Path,
    yes: bool,
) -> Result<bool>
Expand description

Handle legacy format migration (old gitignore-managed → agpm/ subdirectory).

This function detects if a project has resources at old paths (not in agpm/ subdirectory) and offers interactive migration to the new format.

§Behavior

  • Interactive mode: Prompts user with Y/n confirmation (stdin is a TTY)
  • Non-interactive mode: Returns Ok(false) if stdin is not a TTY (e.g., CI/CD)
  • Auto-accept mode: When yes is true, accepts migration without prompting
  • Detection: Uses lockfile to identify AGPM-managed files at old paths

§Arguments

  • project_dir - Path to the project directory
  • yes - When true, automatically accept migration prompts without user interaction

§Returns

  • Ok(true) if migration was performed
  • Ok(false) if no migration needed OR user declined OR non-interactive mode
  • Err if migration failed

§Examples

use agpm_cli::cli::common::handle_legacy_format_migration;
use std::path::Path;

// Interactive mode
let migrated = handle_legacy_format_migration(Path::new("."), false).await?;
if migrated {
    println!("Format migration complete!");
}

// Auto-accept mode (for CI/scripts)
let migrated = handle_legacy_format_migration(Path::new("."), true).await?;