Reorganize parsers right

This commit is contained in:
Darko Poljak 2019-01-28 19:09:36 +01:00
parent 5d3598b96e
commit a77983aead
2 changed files with 37 additions and 37 deletions

View file

@ -161,6 +161,16 @@ def get_parsers():
# Config # Config
parser['config_main'] = argparse.ArgumentParser(add_help=False) parser['config_main'] = argparse.ArgumentParser(add_help=False)
parser['config_main'].add_argument(
'-4', '--force-ipv4',
help=('Force to use IPv4 addresses only. No influence for custom'
' remote commands.'),
action='store_const', dest='force_ipv', const=4)
parser['config_main'].add_argument(
'-6', '--force-ipv6',
help=('Force to use IPv6 addresses only. No influence for custom'
' remote commands.'),
action='store_const', dest='force_ipv', const=6)
parser['config_main'].add_argument( parser['config_main'].add_argument(
'-C', '--cache-path-pattern', '-C', '--cache-path-pattern',
help=('Specify custom cache path pattern. If ' help=('Specify custom cache path pattern. If '
@ -191,6 +201,11 @@ def get_parsers():
parser['config_main'].add_argument( parser['config_main'].add_argument(
'-o', '--out-dir', '-o', '--out-dir',
help='Directory to save cdist output in.', dest="out_path") help='Directory to save cdist output in.', dest="out_path")
parser['config_main'].add_argument(
'-P', '--timestamp',
help=('Timestamp log messages with the current local date and time '
'in the format: YYYYMMDDHHMMSS.us.'),
action='store_true', dest='timestamp')
parser['config_main'].add_argument( parser['config_main'].add_argument(
'-R', '--use-archiving', nargs='?', '-R', '--use-archiving', nargs='?',
choices=('tar', 'tgz', 'tbz2', 'txz',), choices=('tar', 'tgz', 'tbz2', 'txz',),
@ -220,19 +235,13 @@ def get_parsers():
'(should behave like ssh).'), '(should behave like ssh).'),
action='store', dest='remote_exec', action='store', dest='remote_exec',
default=None) default=None)
parser['config_main'].add_argument(
'-S', '--disable-saving-output-streams',
help='Disable saving output streams.',
action='store_false', dest='save_output_streams', default=True)
# Config # Config
parser['config_args'] = argparse.ArgumentParser(add_help=False) parser['config_args'] = argparse.ArgumentParser(add_help=False)
parser['config_args'].add_argument(
'-4', '--force-ipv4',
help=('Force to use IPv4 addresses only. No influence for custom'
' remote commands.'),
action='store_const', dest='force_ipv', const=4)
parser['config_args'].add_argument(
'-6', '--force-ipv6',
help=('Force to use IPv6 addresses only. No influence for custom'
' remote commands.'),
action='store_const', dest='force_ipv', const=6)
parser['config_args'].add_argument( parser['config_args'].add_argument(
'-A', '--all-tagged', '-A', '--all-tagged',
help=('Use all hosts present in tags db. Currently in beta.'), help=('Use all hosts present in tags db. Currently in beta.'),
@ -242,8 +251,6 @@ def get_parsers():
help=('List hosts that have all specified tags, ' help=('List hosts that have all specified tags, '
'if -t/--tag is specified.'), 'if -t/--tag is specified.'),
action="store_true", dest="has_all_tags", default=False) action="store_true", dest="has_all_tags", default=False)
parser['config_args'].add_argument(
'host', nargs='*', help='Host(s) to operate on.')
parser['config_args'].add_argument( parser['config_args'].add_argument(
'-f', '--file', '-f', '--file',
help=('Read specified file for a list of additional hosts to ' help=('Read specified file for a list of additional hosts to '
@ -251,11 +258,6 @@ def get_parsers():
'line). If no host or host file is specified then, by ' 'line). If no host or host file is specified then, by '
'default, read hosts from stdin.'), 'default, read hosts from stdin.'),
dest='hostfile', required=False) dest='hostfile', required=False)
parser['config_args'].add_argument(
'-P', '--timestamp',
help=('Timestamp log messages with the current local date and time '
'in the format: YYYYMMDDHHMMSS.us.'),
action='store_true', dest='timestamp')
parser['config_args'].add_argument( parser['config_args'].add_argument(
'-p', '--parallel', nargs='?', metavar='HOST_MAX', '-p', '--parallel', nargs='?', metavar='HOST_MAX',
type=functools.partial(check_lower_bounded_int, lower_bound=1, type=functools.partial(check_lower_bounded_int, lower_bound=1,
@ -265,10 +267,6 @@ def get_parsers():
'default.'), 'default.'),
action='store', dest='parallel', action='store', dest='parallel',
const=multiprocessing.cpu_count()) const=multiprocessing.cpu_count())
parser['config_args'].add_argument(
'-S', '--disable-saving-output-streams',
help='Disable saving output streams.',
action='store_false', dest='save_output_streams', default=True)
parser['config_args'].add_argument( parser['config_args'].add_argument(
'-s', '--sequential', '-s', '--sequential',
help='Operate on multiple hosts sequentially (default).', help='Operate on multiple hosts sequentially (default).',
@ -279,6 +277,8 @@ def get_parsers():
'list all hosts that contain any of specified tags. ' 'list all hosts that contain any of specified tags. '
'Currently in beta.'), 'Currently in beta.'),
dest='tag', required=False, action="store_true", default=False) dest='tag', required=False, action="store_true", default=False)
parser['config_args'].add_argument(
'host', nargs='*', help='Host(s) to operate on.')
parser['config'] = parser['sub'].add_parser( parser['config'] = parser['sub'].add_parser(
'config', parents=[parser['loglevel'], parser['beta'], 'config', parents=[parser['loglevel'], parser['beta'],
parser['common'], parser['common'],

View file

@ -15,23 +15,23 @@ SYNOPSIS
cdist banner [-h] [-l LOGLEVEL] [-q] [-v] cdist banner [-h] [-l LOGLEVEL] [-q] [-v]
cdist config [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] cdist config [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] [-4]
[-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST] [-6] [-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST]
[-j [JOBS]] [-n] [-o OUT_PATH] [-R [{tar,tgz,tbz2,txz}]] [-j [JOBS]] [-n] [-o OUT_PATH] [-P]
[-r REMOTE_OUT_DIR] [--remote-copy REMOTE_COPY] [-R [{tar,tgz,tbz2,txz}]] [-r REMOTE_OUT_PATH]
[--remote-exec REMOTE_EXEC] [-I INVENTORY_DIR] [-4] [-6] [--remote-copy REMOTE_COPY] [--remote-exec REMOTE_EXEC]
[-A] [-a] [-f HOSTFILE] [-P] [-p [HOST_MAX]] [-S] [-s] [-S] [-I INVENTORY_DIR] [-A] [-a] [-f HOSTFILE]
[-t] [-p [HOST_MAX]] [-s] [-t]
[host [host ...]] [host [host ...]]
cdist install [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] cdist install [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] [-4]
[-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST] [-6] [-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST]
[-j [JOBS]] [-n] [-o OUT_PATH] [-R [{tar,tgz,tbz2,txz}]] [-j [JOBS]] [-n] [-o OUT_PATH] [-P]
[-r REMOTE_OUT_DIR] [--remote-copy REMOTE_COPY] [-R [{tar,tgz,tbz2,txz}]] [-r REMOTE_OUT_PATH]
[--remote-exec REMOTE_EXEC] [-I INVENTORY_DIR] [-4] [-6] [--remote-copy REMOTE_COPY] [--remote-exec REMOTE_EXEC]
[-A] [-a] [-f HOSTFILE] [-P] [-p [HOST_MAX]] [-S] [-s] [-S] [-I INVENTORY_DIR] [-A] [-a] [-f HOSTFILE]
[-t] [-p [HOST_MAX]] [-s] [-t]
[host [host ...]] [host [host ...]]
cdist inventory [-h] {add-host,add-tag,del-host,del-tag,list} ... cdist inventory [-h] {add-host,add-tag,del-host,del-tag,list} ...