Skip to content

Commit

Permalink
ansible-doc fix displaying 'CLI' options for plugin docs
Browse files Browse the repository at this point in the history
cli options will now display either use provided info, or automating from the name


Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
  • Loading branch information
bcoca and s-hertel committed Jun 4, 2021
1 parent 6a883f1 commit 26827f5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/doc_knows_cli.yml
@@ -0,0 +1,2 @@
minor_changes:
- ansible-doc pretty cli options output.
9 changes: 9 additions & 0 deletions lib/ansible/cli/doc.py
Expand Up @@ -1043,6 +1043,15 @@ def add_fields(text, fields, limit, opt_indent, return_values=False, base_indent
if ignore in item:
del item[ignore]

if 'cli' in opt and opt['cli']:
conf['cli'] = []
for cli in opt['cli']:
if 'option' not in cli:
conf['cli'].append({'name': cli['name'], 'option': '--%s' % cli['name'].replace('_', '-')})
else:
conf['cli'].append(cli)
del opt['cli']

if conf:
text.append(DocCLI._dump_yaml({'set_via': conf}, opt_indent))

Expand Down
1 change: 1 addition & 0 deletions lib/ansible/plugins/connection/ssh.py
Expand Up @@ -232,6 +232,7 @@
- name: ansible_ssh_private_key_file
cli:
- name: private_key_file
option: '--private-key'
control_path:
description:
Expand Down

0 comments on commit 26827f5

Please sign in to comment.