From 26827f50393b21a87b8640387cb77ee0801155ea Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 4 Jun 2021 10:22:39 -0400 Subject: [PATCH] ansible-doc fix displaying 'CLI' options for plugin docs 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> --- changelogs/fragments/doc_knows_cli.yml | 2 ++ lib/ansible/cli/doc.py | 9 +++++++++ lib/ansible/plugins/connection/ssh.py | 1 + 3 files changed, 12 insertions(+) create mode 100644 changelogs/fragments/doc_knows_cli.yml diff --git a/changelogs/fragments/doc_knows_cli.yml b/changelogs/fragments/doc_knows_cli.yml new file mode 100644 index 00000000000..d9f5fd65849 --- /dev/null +++ b/changelogs/fragments/doc_knows_cli.yml @@ -0,0 +1,2 @@ +minor_changes: + - ansible-doc pretty cli options output. diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index e6444f145f8..642e2beaec8 100644 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -1043,6 +1043,15 @@ class DocCLI(CLI, RoleMixin): 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)) diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index fa6e0bf83cf..992a71fdb9b 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -232,6 +232,7 @@ DOCUMENTATION = ''' - name: ansible_ssh_private_key_file cli: - name: private_key_file + option: '--private-key' control_path: description: