2022-07-22 15:24:11 -04:00
|
|
|
import code
|
|
|
|
import argparse
|
|
|
|
import importlib
|
|
|
|
import sys
|
|
|
|
|
2022-07-23 14:48:28 -04:00
|
|
|
import src
|
|
|
|
|
2022-07-22 15:24:11 -04:00
|
|
|
BANNER = """
|
|
|
|
. o8o oooo o8o . o8o
|
|
|
|
.o8 `"' `888 `"' .o8 `"'
|
|
|
|
oooo oooo .o888oo oooo 888 oooo .o888oo oooo .ooooo. .oooo.o
|
|
|
|
`888 `888 888 `888 888 `888 888 `888 d88' `88b d88( "8
|
|
|
|
888 888 888 888 888 888 888 888 888ooo888 `"Y88b.
|
|
|
|
888 888 888 . 888 888 888 888 . 888 888 .o o. )88b
|
|
|
|
`V88V"V8P' "888" o888o o888o o888o "888" o888o `Y8bod8P' 8""888P'
|
|
|
|
"""
|
|
|
|
|
2022-07-23 15:09:59 -04:00
|
|
|
|
2022-07-22 15:24:11 -04:00
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
2022-07-23 15:09:59 -04:00
|
|
|
description="Run a specific script by name. If no name is provided, start a REPL."
|
2022-07-22 15:24:11 -04:00
|
|
|
)
|
2022-07-23 14:48:28 -04:00
|
|
|
parser.add_argument(
|
2022-07-23 15:09:59 -04:00
|
|
|
"user_input",
|
2022-07-23 14:48:28 -04:00
|
|
|
type=str,
|
2022-07-23 15:09:59 -04:00
|
|
|
nargs="*",
|
|
|
|
help="The name of the script that you want to run plus any arguments for that script.",
|
|
|
|
)
|
2022-07-23 14:48:28 -04:00
|
|
|
parser.add_argument(
|
2022-07-23 15:09:59 -04:00
|
|
|
"--version", action="store_true", help="Print out the version string."
|
2022-07-23 14:48:28 -04:00
|
|
|
)
|
2022-07-22 15:24:11 -04:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
user_input = args.user_input
|
2022-07-23 14:48:28 -04:00
|
|
|
if args.version is True:
|
|
|
|
print(src.__version__)
|
|
|
|
sys.exit()
|
2022-07-22 15:24:11 -04:00
|
|
|
if len(user_input) == 0:
|
|
|
|
code.interact(banner=BANNER, local=locals())
|
|
|
|
else:
|
|
|
|
command_name = user_input.pop(0)
|
|
|
|
module = importlib.import_module(f"src.commands.{command_name}")
|
|
|
|
sys.exit(module.main(user_input))
|