Split parser creation and parser for inventory

Access to the object separate from parsing allows us to use
argparse-manpage to generate a man page in the Debian package
automatically. We also need to set 'prog' explicitly rather
than let it be picked up via argv[0] so that when we load
the parser via argparse-manpage it produces the right value.

Change-Id: I654b4408444f804f900951333a6ebc3372d5037e
This commit is contained in:
Clint Byrum 2019-01-06 21:07:09 -08:00
parent bea73746c8
commit 186dac6535
1 changed files with 8 additions and 3 deletions

View File

@ -29,8 +29,9 @@ def output_format_dict(data, use_yaml):
return json.dumps(data, sort_keys=True, indent=2)
def parse_args():
parser = argparse.ArgumentParser(description='OpenStack Inventory Module')
def get_parser():
parser = argparse.ArgumentParser(description='OpenStack Inventory Module',
prog='shade-inventory')
parser.add_argument('--refresh', action='store_true',
help='Refresh cached information')
group = parser.add_mutually_exclusive_group(required=True)
@ -45,7 +46,11 @@ def parse_args():
help='Output data in nicely readable yaml')
parser.add_argument('--debug', action='store_true', default=False,
help='Enable debug output')
return parser.parse_args()
return parser
def parse_args():
return get_parser().parse_args()
def main():