From 79ef2bbd848b8258771291a2d1d5e0bd1e0f1252 Mon Sep 17 00:00:00 2001 From: Peter Stachowski Date: Mon, 18 Apr 2016 20:54:51 +0000 Subject: [PATCH] [cli-ref] Fix wrong delim splitting subcommands - fixed issue where 'complete' generated wrong subcommands if they were hyphenated. - fixed issue where 'hardcoded' subcommands (in clients.yaml) were ignored. - added 'auth' to list of swift commands Change-Id: If929299e38f21f3420d3fcb70a11daaa11c067bf --- os_doc_tools/commands.py | 19 +++++++++++++------ os_doc_tools/resources/clients.yaml | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/os_doc_tools/commands.py b/os_doc_tools/commands.py index f868af1c..b5b56d78 100644 --- a/os_doc_tools/commands.py +++ b/os_doc_tools/commands.py @@ -530,14 +530,19 @@ def discover_subcommands(os_command, subcommands, extra_params): if subcommands == 'complete': subcommands = [] args.append('complete') - for line in [x.strip() for x in - subprocess.check_output( - args, - universal_newlines=True, - stderr=DEVNULL).split('\n') + lines = subprocess.check_output( + args, universal_newlines=True, stderr=DEVNULL).split('\n') + delim = ' ' + # if the cmds= line contains '-' then use that as a delim + for line in lines: + if '-' in line and 'cmds=' in line: + delim = '-' + break + for line in [x.strip() for x in lines if x.strip().startswith('cmds_') and '-' in x]: subcommand, _ = line.split('=') - subcommand = subcommand.replace('cmds_', '').replace('_', ' ') + subcommand = subcommand.replace( + 'cmds_', '').replace('_', delim) subcommands.append(subcommand) else: args.append('bash-completion') @@ -618,6 +623,8 @@ def document_single_project(os_command, output_dir): out_file = open(os.path.join(output_dir, out_filename), 'w') generate_heading(os_command, api_name, title, out_file) subcommands = generate_command(os_command, out_file) + if subcommands == 'complete' and data.get('subcommands'): + subcommands = data.get('subcommands') if os_command == 'cinder': format_heading("Block Storage API v2 commands", 2, out_file) diff --git a/os_doc_tools/resources/clients.yaml b/os_doc_tools/resources/clients.yaml index ee3fad96..426cf8da 100644 --- a/os_doc_tools/resources/clients.yaml +++ b/os_doc_tools/resources/clients.yaml @@ -53,6 +53,7 @@ solum: swift: name: Object Storage service subcommands: + - auth - capabilities - delete - download