[cli-ref] Added support for 'help' and 'version'
- added --version option. - added support for printing help if no options given, or if 'help' was used (i.e. 'openstack-auto-commands help') openstack-manuals was also added to .gitignore so that running the 'doc-tools-update-cli-reference' script will not affect the os_doc_tools repo if the tool is run within the repo. Change-Id: I4c5ac6e7f207cd953040ce7b40cf1a5f13acf709
This commit is contained in:
parent
5034807430
commit
52fb24a51e
3
.gitignore
vendored
3
.gitignore
vendored
@ -38,3 +38,6 @@ build_environment/repositories/
|
||||
|
||||
# Files created by releasenotes build
|
||||
releasenotes/build
|
||||
|
||||
# repo pulled down by doc-tools-update-cli-reference
|
||||
openstack-manuals
|
||||
|
@ -308,12 +308,12 @@ def generate_command(os_command, os_file):
|
||||
:param os_file: open filehandle for output of RST file
|
||||
"""
|
||||
|
||||
if os_command == "glance":
|
||||
help_lines = subprocess.check_output([os_command, "help"],
|
||||
if use_help_flag(os_command):
|
||||
help_lines = subprocess.check_output([os_command, "--help"],
|
||||
universal_newlines=True,
|
||||
stderr=DEVNULL).split('\n')
|
||||
else:
|
||||
help_lines = subprocess.check_output([os_command, "--help"],
|
||||
help_lines = subprocess.check_output([os_command, "help"],
|
||||
universal_newlines=True,
|
||||
stderr=DEVNULL).split('\n')
|
||||
|
||||
@ -381,6 +381,7 @@ def generate_command(os_command, os_file):
|
||||
next_line_screen = True
|
||||
ignore_next_lines = False
|
||||
continue
|
||||
# all
|
||||
if not line.startswith('usage'):
|
||||
continue
|
||||
if not ignore_next_lines:
|
||||
@ -760,6 +761,9 @@ def main():
|
||||
help="Continue with remaining clients even if an "
|
||||
"error occurs generating a client file.",
|
||||
action="store_true")
|
||||
parser.add_argument("--version", default=False,
|
||||
help="Show program's version number and exit.",
|
||||
action="store_true")
|
||||
prog_args = parser.parse_args()
|
||||
|
||||
client_list = []
|
||||
@ -771,6 +775,13 @@ def main():
|
||||
elif prog_args.clients:
|
||||
client_list = prog_args.clients
|
||||
|
||||
if not prog_args or 'help' in [client.lower() for client in client_list]:
|
||||
parser.print_help()
|
||||
sys.exit(0)
|
||||
elif prog_args.version:
|
||||
print(os_doc_tools.__version__)
|
||||
sys.exit(0)
|
||||
|
||||
if not client_list:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user