From b758ee7c7d9edfb44e618ef43b6d5332c3a18ad6 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Wed, 13 Jan 2021 11:42:06 +0100 Subject: [PATCH] Improved Argument Parser to stop the bot instantly --- run.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/run.py b/run.py index 5267cd3..5658075 100644 --- a/run.py +++ b/run.py @@ -57,21 +57,25 @@ async def train(): async def on_ready(): print("Logged in!") args = sys.argv + args.pop(0) for arg in args: - if arg == "--help" or "-?": + if arg == "--help" or arg == "-?": printhelp() await bot.close() - if arg == "--version" or "-v": + raise SystemExit(0) + if arg == "--version" or arg == "-v": printversion() await bot.close() - if arg == "--download" or "-d": + raise SystemExit(0) + if arg == "--download" or arg == "-d": tasks[0] = True - if arg == "--train" or "-t": + if arg == "--train" or arg == "-t": tasks[1] = True else: print(f"Unexspected {arg}") printhelp() await bot.close() + raise SystemExit(1) if tasks[0]: await download() if tasks[1]: