[Bash-completion-commits] [bash-completion] 09/11: puppet: Parse most subcommand options from "help subcommand" output

Ville Skyttä scop-guest at moszumanska.debian.org
Mon Jun 2 09:42:34 UTC 2014


This is an automated email from the git hooks/post-receive script.

scop-guest pushed a commit to branch master
in repository bash-completion.

commit 00a80a2a830cc5cfea262865e5d97d1f901ca177
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Mon Jun 2 12:35:14 2014 +0300

    puppet: Parse most subcommand options from "help subcommand" output
---
 completions/puppet | 45 +++++++++++++++++++++------------------------
 1 file changed, 21 insertions(+), 24 deletions(-)

diff --git a/completions/puppet b/completions/puppet
index 310f500..a1acb20 100644
--- a/completions/puppet
+++ b/completions/puppet
@@ -45,6 +45,14 @@ _puppet_references()
     COMPREPLY+=( $( compgen -W "$puppet_doc_list" -- "$cur" ) )
 }
 
+_puppet_subcmd_opts()
+{
+    # puppet cmd help is somewhat slow, avoid if possible
+    [[ -z $cur || $cur == -* ]] && \
+        COMPREPLY+=( $( compgen -W \
+        '$( _parse_usage "$1" "help $2" )' -- "$cur" ) )
+}
+
 _puppet()
 {
     local cur prev words cword
@@ -130,10 +138,9 @@ _puppet()
                     return 0
                     ;;
                 *)
-                    COMPREPLY=( $( compgen -W '--certname --daemonize --no-daemonize
-                        --debug --detailed-exitcodes --digest --disable --enable --fingerprint
-                        --help --logdest --masterport --no-client --noop --onetime --test
-                        --verbose --version --waitforcert' -- "$cur" ) )
+                    _puppet_subcmd_opts "$1" $subcommand
+                    # _parse_usage doesn't grok [-D|--daemonize|--no-daemonize]
+                    COMPREPLY+=( $( compgen -W '--no-daemonize' -- "$cur" ) )
                     return 0
             esac
             ;;
@@ -153,9 +160,7 @@ _puppet()
                     ;;
                 *)
                     if [[ "$cur" == -* ]]; then
-                        COMPREPLY=( $( compgen -W '--debug --detailed-exitcodes --help
-                            --loadclasses --logdest --noop --execute --test --verbose
-                            --catalog --write-catalog-summary' -- "$cur" ) )
+                        _puppet_subcmd_opts "$1" $subcommand
                     else
                         _filedir
                     fi
@@ -199,7 +204,7 @@ _puppet()
             esac
             ;;
         describe)
-            COMPREPLY=( $( compgen -W '--help --providers --list --meta --short' -- "$cur" ) )
+            _puppet_subcmd_opts "$1" $subcommand
             if [[ "$cur" != -* ]]; then
                 _puppet_types
             fi
@@ -221,8 +226,7 @@ _puppet()
                     ;;
                 *)
                     if [[ "$cur" == -* ]]; then
-                        COMPREPLY=( $( compgen -W '--all --help --outputdir
-                            --mode --reference --charset --list' -- "$cur" ) )
+                        _puppet_subcmd_opts "$1" $subcommand
                     else
                         _filedir
                     fi
@@ -241,9 +245,7 @@ _puppet()
                     ;;
                 *)
                     if [[ "$cur" == -* ]]; then
-                        COMPREPLY=( $( compgen -W '--help --version --debug
-                            --verbose --local --remote --server --bucket' \
-                                -- "$cur" ) )
+                        _puppet_subcmd_opts "$1" $subcommand
                     else
                         COMPREPLY=( $( compgen -W 'backup get restore' \
                             -- "$cur" ) )
@@ -266,9 +268,7 @@ _puppet()
                     ;;
                 *)
                     if [[ "$cur" == -* ]]; then
-                        COMPREPLY=( $( compgen -W '--all --class --debug
-                            --foreground --help --host --no-fqdn
-                            --ignoreschedules --tag --test --ping' -- "$cur" ) )
+                        _puppet_subcmd_opts "$1" $subcommand
                     else
                         _known_hosts_real "$cur"
                     fi
@@ -282,9 +282,9 @@ _puppet()
                     return 0
                     ;;
                 *)
-                    COMPREPLY=( $( compgen -W '--daemonize --no-daemonize
-                        --debug --help --logdest --verbose --version' \
-                            -- "$cur" ) )
+                    _puppet_subcmd_opts "$1" $subcommand
+                    # _parse_usage doesn't grok [-D|--daemonize|--no-daemonize]
+                    COMPREPLY+=( $( compgen -W '--no-daemonize' -- "$cur" ) )
                     return 0
             esac
             ;;
@@ -308,9 +308,7 @@ _puppet()
                     ;;
                 *)
                     if [[ "$cur" == -* ]]; then
-                        COMPREPLY=( $( compgen -W '--help --version --debug
-                            --verbose --execute --detailed-exitcodes
-                            --logdest' -- "$cur" ) )
+                        _puppet_subcmd_opts "$1" $subcommand
                     else
                         _filedir
                     fi
@@ -318,8 +316,7 @@ _puppet()
             esac
             ;;
         resource|*)
-            COMPREPLY=( $( compgen -W '--help --version --debug --verbose' \
-                -- "$cur" ) )
+            _puppet_subcmd_opts "$1" $subcommand
             return 0
             ;;
     esac

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/bash-completion/bash-completion.git



More information about the Bash-completion-commits mailing list