()
| 63 | |
| 64 | |
| 65 | def _parse_args() -> argparse.Namespace: |
| 66 | parser = argparse.ArgumentParser( |
| 67 | prog="mzimage", |
| 68 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 69 | description="Swiss army knife for mzbuild images.", |
| 70 | epilog="For additional help on a subcommand, run:\n\n %(prog)s <command> -h", |
| 71 | ) |
| 72 | subparsers = parser.add_subparsers( |
| 73 | dest="command", metavar="<command>", required=True |
| 74 | ) |
| 75 | |
| 76 | def add_subcommand(name: str, **kwargs: Any) -> argparse.ArgumentParser: |
| 77 | subparser = subparsers.add_parser(name, **kwargs) |
| 78 | mzbuild.Repository.install_arguments(subparser) |
| 79 | return subparser |
| 80 | |
| 81 | def add_image_subcommand(name: str, **kwargs: Any) -> argparse.ArgumentParser: |
| 82 | subparser = add_subcommand(name, **kwargs) |
| 83 | subparser.add_argument( |
| 84 | "image", help="the name of an mzbuild image in this repository" |
| 85 | ) |
| 86 | return subparser |
| 87 | |
| 88 | add_subcommand( |
| 89 | "list", |
| 90 | description="List all images in this repository.", |
| 91 | help="list all images", |
| 92 | ) |
| 93 | |
| 94 | add_image_subcommand( |
| 95 | "acquire", description="Download or build an image.", help="acquire an image" |
| 96 | ) |
| 97 | add_image_subcommand( |
| 98 | "ensure", |
| 99 | description="Ensure an image exists in the remote registry.", |
| 100 | help="ensure an image", |
| 101 | ) |
| 102 | |
| 103 | run_parser = add_image_subcommand( |
| 104 | "run", description="Acquire and run an image.", help="run an image" |
| 105 | ) |
| 106 | run_parser.add_argument("image_args", nargs=argparse.REMAINDER) |
| 107 | |
| 108 | add_image_subcommand( |
| 109 | "fingerprint", |
| 110 | description="Compute the fingerprint for an image.", |
| 111 | help="fingerprint an image", |
| 112 | ) |
| 113 | |
| 114 | add_image_subcommand( |
| 115 | "spec", |
| 116 | description="Compute the Docker Hub specification for an image.", |
| 117 | help="compute image spec", |
| 118 | ) |
| 119 | |
| 120 | describe_parser = add_image_subcommand( |
| 121 | "describe", |
| 122 | description="Print information about an image.", |
no test coverage detected