Commit 0c0ac930 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Script: Add gui, help and debug commands.

Showing with 15 additions and 6 deletions
+15 -6
......@@ -41,17 +41,20 @@ from init import license, setup_lang
logger = logging.getLogger()
scripts = {
"gui" : None,
"hello": ScriptHello,
}
def usage(argv):
logger.error(f"{logger_color_red()}Invalid script name '{argv[1]}'{logger_color_reset()}")
logger.info("")
logger.info(f"Usage: {argv[0]} <script> <args...>")
logger.info(f"")
logger.info(f"Valid scripts:")
logger.info("")
logger.info(f"Available scripts:")
logger.info(f"\thelp\t\tDisplay this help")
logger.info(f"\tgui\t\tRun Pamhyr graphics user interface (by default)")
logger.info(f"\tdebug\t\tRun Pamhyr graphics user interface as debug mode")
for s in scripts:
logger.info(f"\t{s}\t\t{scripts[s].name}: {scripts[s].description}")
logger.info(f"\t{s}\t\t{scripts[s].description}")
logger.info("")
def gui(app:QApplication, conf:Config):
application = ApplicationWindow(conf=conf)
......@@ -72,10 +75,16 @@ def main():
# Run a script
script = sys.argv[1]
if script == "gui":
if script == "help":
ret = usage(sys.argv)
elif script == "gui":
ret = gui(app, conf)
elif script == "debug":
conf.debug = True
ret = gui(app, conf)
else:
if script not in scripts:
logger.error(f"{logger_color_red()}Invalid script name '{sys.argv[1]}'{logger_color_reset()}")
usage(sys.argv)
sys.exit(-1)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment