38 lines
971 B
Python
Executable File
38 lines
971 B
Python
Executable File
#! /usr/bin/env python
|
|
import argparse
|
|
import sys
|
|
import logging
|
|
import subprocess
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def main() -> int:
|
|
# Handle program arguments
|
|
ap = argparse.ArgumentParser(prog="basejump")
|
|
ap.add_argument(
|
|
"subcommand", help="The subcommand to run", choices=["init", "fetch", "discover"]
|
|
)
|
|
ap.add_argument("arguments", nargs=argparse.REMAINDER)
|
|
args = ap.parse_args()
|
|
|
|
# Configure logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="%(levelname)s: %(message)s",
|
|
)
|
|
|
|
# Execute the appropriate subcommand
|
|
real_command_name = f"basejump-{args.subcommand}"
|
|
try:
|
|
return subprocess.run([real_command_name] + args.arguments).returncode
|
|
except FileNotFoundError:
|
|
logger.error(f"Unknown subcommand: {args.subcommand}")
|
|
logger.error(f"Could not find `{real_command_name}` in $PATH")
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|