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:
parent
bea73746c8
commit
186dac6535
|
@ -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():
|
||||
|
|
Loading…
Reference in New Issue