2023-08-08 09:38:43 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import argparse
|
2023-08-29 03:15:16 +00:00
|
|
|
import sys
|
2023-08-08 09:38:43 +00:00
|
|
|
|
|
|
|
from .bundle import attach_bundle_commands
|
2023-08-29 03:15:16 +00:00
|
|
|
from .source import attach_source_commands
|
2023-08-08 09:38:43 +00:00
|
|
|
from .dev import attach_dev_commands
|
2023-08-29 03:15:16 +00:00
|
|
|
from .version import attach_version_command
|
2023-08-08 09:38:43 +00:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
2023-08-29 03:15:16 +00:00
|
|
|
parser.add_argument("-?", action="help", help=argparse.SUPPRESS)
|
2023-08-08 09:38:43 +00:00
|
|
|
|
2023-08-29 03:15:16 +00:00
|
|
|
subparsers = parser.add_subparsers(required=True, title="commands")
|
2023-08-08 09:38:43 +00:00
|
|
|
attach_bundle_commands(subparsers)
|
2023-08-29 03:15:16 +00:00
|
|
|
attach_source_commands(subparsers)
|
2023-08-08 09:38:43 +00:00
|
|
|
attach_dev_commands(subparsers)
|
2023-08-29 03:15:16 +00:00
|
|
|
attach_version_command(subparsers)
|
2023-08-08 09:38:43 +00:00
|
|
|
|
2023-08-29 03:15:16 +00:00
|
|
|
# Hack to run the actual version command if we pass -v or --version.
|
|
|
|
# Using argparse action="version" requires us to pass a single string
|
|
|
|
# and doesn't allow us to run our own custom version-printing function.
|
|
|
|
argv = sys.argv[1:]
|
2023-09-16 16:59:02 +00:00
|
|
|
|
|
|
|
if len(argv) == 0:
|
|
|
|
argv = ["-h"]
|
|
|
|
elif argv[0] in ["-v", "--version"]:
|
2023-08-29 03:15:16 +00:00
|
|
|
argv = ["version"]
|
|
|
|
|
|
|
|
args = parser.parse_args(argv)
|
2023-08-08 09:38:43 +00:00
|
|
|
args.func(args)
|