[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
This commit is contained in:
Peter Stachowski 2016-04-18 20:54:51 +00:00
parent 28dae6445b
commit 79ef2bbd84
2 changed files with 14 additions and 6 deletions

View File

@ -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)

View File

@ -53,6 +53,7 @@ solum:
swift:
name: Object Storage service
subcommands:
- auth
- capabilities
- delete
- download