use ../lib_provisioning/config/accessor.nu *

# Distribution packaging (Advanced/Maintainer)
export def "main pack" [
  ...args  # Pack command arguments
  --infra (-i): string    # Infra path
  --check (-c)            # Check mode only
  --out: string           # Output format: json, yaml, text
  --debug (-x)            # Debug mode
  --notitles              # Do not show banner titles
  --dry-run               # Show what would be done without doing it
  --force (-f)            # Skip confirmation prompts
  --all                   # Clean ALL packages (use with clean)
  --keep-latest: int      # Keep N latest versions (use with clean)
] {
  # Forward to run_module system via main router
  let cmd_args = ([$args] | flatten | str join " ")
  let infra_flag = if ($infra | is-not-empty) { $"--infra ($infra)" } else { "" }
  let check_flag = if $check { "--check" } else { "" }
  let out_flag = if ($out | is-not-empty) { $"--out ($out)" } else { "" }
  let debug_flag = if $debug { "--debug" } else { "" }
  let notitles_flag = if $notitles { "--notitles" } else { "" }
  let dry_run_flag = if $dry_run { "--dry-run" } else { "" }
  let force_flag = if $force { "--force" } else { "" }
  let all_flag = if $all { "--all" } else { "" }
  let keep_latest_flag = if ($keep_latest | is-not-empty) { $"--keep-latest ($keep_latest)" } else { "" }

  ^($env.PROVISIONING_NAME) "pack" $cmd_args $infra_flag $check_flag $out_flag $debug_flag $notitles_flag $dry_run_flag $force_flag $all_flag $keep_latest_flag
}
