Added explicit --help option.

argparse.ArgumentParser doesn't seem to add the option automatically
anymore.
This commit is contained in:
Fabio Manganiello 2023-07-24 02:11:42 +02:00
parent e9a568fdd2
commit 1304be0718

View file

@ -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,