#!/usr/bin/env python3
import argparse
import shutil
from pathlib import Path

from script_common import resolve_repo_root


def main() -> int:
    parser = argparse.ArgumentParser(description="Import NuGet cache from zip")
    parser.add_argument("--repo-root", default=None)
    parser.add_argument("--input-zip", default="nuget-cache-export.zip")
    args = parser.parse_args()

    repo_root = resolve_repo_root(args.repo_root)
    input_zip = (repo_root / args.input_zip).resolve()
    if not input_zip.exists():
        print(f"Input zip not found: {input_zip}")
        return 2

    shutil.unpack_archive(str(input_zip), extract_dir=str(repo_root))
    print(f"Imported cache from: {input_zip}")
    print("Run `python scripts/dotnet-min.py restore` to validate restore in this repo.")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
