From 2be1d367df1b5bfb6996545630ab7a844768c9f9 Mon Sep 17 00:00:00 2001 From: derrod Date: Tue, 28 Apr 2020 06:14:17 +0200 Subject: [PATCH] [cli] Add version and release codename to help --- legendary/__init__.py | 1 + legendary/cli.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/legendary/__init__.py b/legendary/__init__.py index a992aed..bfba77d 100644 --- a/legendary/__init__.py +++ b/legendary/__init__.py @@ -1,3 +1,4 @@ """Legendary!""" __version__ = '0.0.4' +__codename__ = 'Unforeseen Consequences' diff --git a/legendary/cli.py b/legendary/cli.py index 0e9e2f9..3e08a12 100644 --- a/legendary/cli.py +++ b/legendary/cli.py @@ -13,6 +13,7 @@ from logging.handlers import QueueHandler, QueueListener from multiprocessing import freeze_support, Queue as MPQueue from sys import exit +from legendary import __version__, __codename__ from legendary.core import LegendaryCore from legendary.models.exceptions import InvalidCredentialsError @@ -320,11 +321,12 @@ class LegendaryCLI: def main(): - parser = argparse.ArgumentParser(description='Legendary Game Launcher') + parser = argparse.ArgumentParser(description=f'Legendary v{__version__} - "{__codename__}"') # general arguments parser.add_argument('-v', dest='debug', action='store_true', help='Set loglevel to debug') parser.add_argument('-y', dest='yes', action='store_true', help='Default to yes for all prompts') + parser.add_argument('-V', dest='version', action='store_true', help='Print version and exit') # all the commands subparsers = parser.add_subparsers(title='Commands', dest='subparser_name') @@ -385,6 +387,10 @@ def main(): args, extra = parser.parse_known_args() + if args.version: + print(f'legendary version "{__version__}", codename "{__codename__}"') + exit(0) + if args.subparser_name not in ('auth', 'list-games', 'list-installed', 'launch', 'download', 'uninstall'): print(parser.format_help())