()
| 17 | |
| 18 | |
| 19 | def main() -> int: |
| 20 | args = _parse_args() |
| 21 | ui.Verbosity.init_from_env(explicit=None) |
| 22 | repo = mzbuild.Repository.from_arguments(MZ_ROOT, args) |
| 23 | |
| 24 | if args.command == "list": |
| 25 | for image in repo: |
| 26 | print(image.name) |
| 27 | else: |
| 28 | if args.image not in repo.images: |
| 29 | print(f"fatal: unknown image: {args.image}", file=sys.stderr) |
| 30 | return 1 |
| 31 | deps = repo.resolve_dependencies([repo.images[args.image]]) |
| 32 | rimage = deps[args.image] |
| 33 | if args.command == "run": |
| 34 | deps.acquire() |
| 35 | rimage.run(args.image_args) |
| 36 | elif args.command == "acquire": |
| 37 | deps.acquire() |
| 38 | elif args.command == "ensure": |
| 39 | deps.ensure() |
| 40 | elif args.command == "fingerprint": |
| 41 | print(rimage.fingerprint()) |
| 42 | elif args.command == "spec": |
| 43 | print(rimage.spec()) |
| 44 | elif args.command == "describe": |
| 45 | inputs = sorted(rimage.inputs(args.transitive)) |
| 46 | dependencies = sorted(rimage.list_dependencies(args.transitive)) |
| 47 | |
| 48 | print(f"Image: {rimage.name}") |
| 49 | print(f"Fingerprint: {rimage.fingerprint()}") |
| 50 | |
| 51 | print("Input files:") |
| 52 | for inp in inputs: |
| 53 | print(f" {inp}") |
| 54 | |
| 55 | print("Dependencies:") |
| 56 | for d in dependencies: |
| 57 | print(f" {d}") |
| 58 | if not dependencies: |
| 59 | print(" (none)") |
| 60 | else: |
| 61 | raise RuntimeError("unreachable") |
| 62 | return 0 |
| 63 | |
| 64 | |
| 65 | def _parse_args() -> argparse.Namespace: |
no test coverage detected