From 1304be07182e66997411211e855fe4110adb7f84 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 24 Jul 2023 02:11:42 +0200 Subject: [PATCH] Added explicit --help option. argparse.ArgumentParser doesn't seem to add the option automatically anymore. --- platypush/app.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/platypush/app.py b/platypush/app.py index 702d4f793..92e0cca2b 100644 --- a/platypush/app.py +++ b/platypush/app.py @@ -134,7 +134,7 @@ class Application: port = self._redis_conf['port'] log.info('Starting local Redis instance on %s', port) - self._redis_proc = subprocess.Popen( + self._redis_proc = subprocess.Popen( # pylint: disable=consider-using-with [ 'redis-server', '--bind', @@ -163,7 +163,9 @@ class Application: """ from . import __version__ - parser = argparse.ArgumentParser() + parser = argparse.ArgumentParser( + description='A general-purpose platform for automation' + ) parser.add_argument( '--config', @@ -174,6 +176,15 @@ class Application: help='Custom location for the configuration file', ) + parser.add_argument( + '--help', + '-h', + dest='help', + required=False, + action='store_true', + help="Print this help and exit", + ) + parser.add_argument( '--version', dest='version', @@ -260,10 +271,15 @@ class Application: ) opts, _ = parser.parse_known_args(args) + if opts.version: print(__version__) sys.exit(0) + if opts.help: + parser.print_help() + sys.exit(0) + return cls( config_file=opts.config, pidfile=opts.pidfile,