[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-23-ga29ed87

Guillaume Rousse Guillaume.Rousse at inria.fr
Wed Feb 23 20:42:15 UTC 2011


The following commit has been merged in the master branch:
commit dac9622e903404f390c0de2265465d3a214e3f9e
Author: Guillaume Rousse <Guillaume.Rousse at inria.fr>
Date:   Wed Feb 23 21:14:35 2011 +0100

    add puppet completion

diff --git a/CHANGES b/CHANGES
index 40a8028..ac0c06f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,9 @@ bash-completion (2.x)
   * Drop rpm query support for rpm < 4.1.
   * Split rpm and rpmbuild completions and improve them both.
 
+  [ Guillaume Rousse ]
+  * added puppet completion, using work from Mathieu Parent (sathieudebian.org)
+
  -- David Paleino <d.paleino at gmail.com>  Sun, 06 Feb 2011 21:46:37 +0100
 
 bash-completion (1.3)
diff --git a/completions/Makefile.am b/completions/Makefile.am
index 38cd986..e7e86d8 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -120,6 +120,7 @@ bashcomp_DATA = abook \
 		postgresql \
 		povray \
 		procps \
+		puppet \
 		python \
 		qdbus \
 		qemu \
diff --git a/completions/puppet b/completions/puppet
new file mode 100644
index 0000000..fe14909
--- /dev/null
+++ b/completions/puppet
@@ -0,0 +1,294 @@
+# bash completion for puppet
+
+_puppet_logdest()
+{
+    if [ -z "$cur" ]; then
+        COMPREPLY=( $( compgen -W "syslog console /" -- "$cur" ) )
+    else
+        COMPREPLY=( $( compgen -W "syslog console" -- "$cur" ) )
+        _filedir
+    fi
+}
+
+_puppet_digest()
+{
+    COMPREPLY=( $( compgen -W "MD5 MD2 SHA1 SHA256" -- "$cur" ) )
+}
+
+_puppet_certs()
+{
+    local puppetca="puppet cert"
+    PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetca  &>/dev/null && puppetca=puppetca
+    
+    if [[ "$1" = "--all" ]]; then
+        cert_list=`$puppetca --list --all | sed -e 's/^[+-]\?\s*\(\S\+\)\s\+.*$/\1/'`
+    else
+        cert_list=`$puppetca --list`
+    fi
+    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$cert_list" -- "$cur" ) )
+}
+
+_puppet_types()
+{
+    puppet_types=`puppet describe --list | sed -e 's/^\(\S\+\).*$/\1/'`
+    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$puppet_types" -- "$cur" ) )
+}
+
+_puppet_references()
+{
+    local puppetdoc="puppet doc"
+    PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type puppetdoc  &>/dev/null && puppetdoc=puppetdoc
+
+    puppet_doc_list=`$puppetdoc --list | sed -e 's/^\(\S\+\).*$/\1/'`
+    COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "$puppet_doc_list" -- "$cur" ) )
+}
+
+have puppetmasterd || have puppetd || have puppetca || have ralsh || \
+have puppetrun || have puppetqd || have filebucket || have puppetdoc && \
+_puppet()
+{
+    local cur prev xspec helpopts
+
+    COMPREPLY=()
+    _get_comp_words_by_ref cur prev
+
+    case $prev in
+        --help)
+            return 0
+            ;;
+    esac
+
+    puppet_commands='agent apply cert describe doc filebucket kick master queue resource'
+
+    case ${COMP_WORDS[0]} in
+        puppetmasterd)
+            special=master
+            ;;
+        puppetd)
+            special=agent
+            ;;
+        puppetca)
+            special=cert
+            ;;
+        ralsh)
+            special=resource
+            ;;
+        puppetrun)
+            special=kick
+            ;;
+        puppetqd)
+            special=queue
+            ;;
+        filebucket)
+            special=filebucket
+            ;;
+        puppetdoc)
+            special=doc
+            ;;
+        pi)
+            special=describe
+            ;;
+        puppet)
+            case ${COMP_WORDS[1]} in
+               agent|apply|cert|describe|doc|filebucket|kick|master|queue|resource)
+                   special=${COMP_WORDS[1]}
+                   ;;
+               *.pp|*.rb|-*)
+                   special=apply
+                   ;;
+               *)
+                  COMPREPLY=( $( compgen -W "$puppet_commands" -- "$cur" ) )
+                  return 0
+                  ;;
+            esac
+    esac
+
+    case $special in
+        agent)
+            case $prev in
+                --fqdn)
+                    return 0
+                ;;
+                --logdest)
+                    _puppet_logdest
+                    return 0
+                ;;
+                --serve)
+                    # From /usr/lib/ruby/1.8/puppet/network/handler/
+                    COMPREPLY=( $( compgen -W "ca filebucket fileserver master report runner status" -- "$cur" ) )
+                    return 0
+                ;;
+                --digest)
+                    _puppet_digest
+                    return 0
+                ;;
+                --waitforcert)
+                    COMPREPLY=( $( compgen -W "0 15 30 60 120" -- "$cur" ) )
+                    return 0
+                ;;
+                *)
+                    COMPREPLY=( $( compgen -W "--daemonize --no-daemonize --debug --detailed-exitcodes --disable --enable --help --fqdn --logdest --onetime --serve --test --noop --digest --fingerprint --version --verbose --waitforcert --no-client" -- "$cur" ) )
+                    return 0
+            esac
+            ;;
+        apply)
+            case $prev in
+                --logdest)
+                    _puppet_logdest
+                    return 0
+                    ;;
+                *)
+                    if [[ "$cur" == -* ]]; then
+                        COMPREPLY=( $( compgen -W "--help --version --debug --verbose --execute --detailed-exitcodes --logdest" -- "$cur" ) )
+                    else
+                        _filedir
+                    fi
+                    return 0
+            esac
+            ;; 
+        cert)
+            case $prev in
+                --digest)
+                    _puppet_digest
+                    return 0
+                    ;;
+                *)
+                    subspecial=$prev
+                    COMPREPLY=( $( compgen -W "--digest --debug --verbose" -- "$cur" ) )
+                    case $subspecial in
+                        --generate)
+                            _known_hosts_real "$cur"
+                            return 0
+                            ;;
+                        --clean|--fingerprint|--revoke|--verify)
+                            COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "--all" -- "$cur" ) )
+                            _puppet_certs --all
+                            return 0
+                            ;;
+                        --sign)
+                            COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "--all" -- "$cur" ) )
+                            _puppet_certs
+                            return 0
+                            ;;
+                        --list|--print)
+                            COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "--all" -- "$cur" ) )
+                            return 0
+                            ;;
+                        *)
+                            COMPREPLY=( $( compgen -W "--clean --generate --help --list --print --fingerprint --revoke --sign --version --verify" -- "$cur" ) )
+                            return 0
+                    esac
+            esac
+            ;; 
+        describe)
+            if [[ "$cur" == -* ]]; then
+                COMPREPLY=( $( compgen -W "--help --short --providers --list --meta" -- "$cur" ) )
+            else
+                _puppet_types
+            fi
+            return 0
+            ;; 
+        doc)
+            case $prev in
+                --outputdir)
+                    _filedir -d
+                    return 0
+                    ;;
+                --mode)
+                    COMPREPLY=( $( compgen -W "text trac pdf rdoc" -- "$cur" ) )
+                    return 0
+                    ;;
+                --reference)
+                    _puppet_references
+                    return 0
+                    ;;
+                *)
+                    if [[ "$cur" == -* ]]; then
+                        COMPREPLY=( $( compgen -W "--all --help --outputdir --mode --reference --charset --list" -- "$cur" ) )
+                    else
+                        _filedir
+                    fi
+                    return 0
+            esac
+            ;; 
+        filebucket)
+            case $prev in
+                --server)
+                    return 0
+                    ;;
+                --bucket)
+                    _filedir -d
+                    return 0
+                    ;;
+                *)
+                    if [[ "$cur" == -* ]]; then
+                        COMPREPLY=( $( compgen -W "--help --version --debug --verbose --local --remote --server --bucket" -- "$cur" ) )
+                    else
+                        COMPREPLY=( $( compgen -W "backup get restore" -- "$cur" ) )
+                        _filedir
+                    fi
+                    return 0
+            esac
+            ;; 
+        kick)
+            case $prev in
+                --class)
+                    return 0
+                    ;;
+                --host)
+                    _known_hosts_real "$cur" 
+                    return 0
+                    ;;
+                --tag)
+                    return 0
+                    ;;
+                *)
+                    if [[ "$cur" == -* ]]; then
+                        COMPREPLY=( $( compgen -W "--all --class --debug --foreground --help --host --no-fqdn --ignoreschedules --tag --test --ping" -- "$cur" ) )
+                    else
+                        _known_hosts_real "$cur"
+                    fi
+                    return 0
+            esac
+            ;; 
+        master)
+            case $prev in
+                --logdest)
+                    _puppet_logdest
+                    return 0
+                    ;;
+                *)
+                    COMPREPLY=( $( compgen -W "--daemonize --no-daemonize --debug --help --logdest --verbose --version" -- "$cur" ) )
+                    return 0
+            esac
+            ;; 
+        queue)
+            case $prev in
+                --logdest)
+                    _puppet_logdest
+                    return 0
+                    ;;
+                *)
+                    if [[ "$cur" == -* ]]; then
+                        COMPREPLY=( $( compgen -W "--help --version --debug --verbose --execute --detailed-exitcodes --logdest" -- "$cur" ) )
+                    else
+                        _filedir
+                    fi
+                    return 0
+            esac
+            ;; 
+        resource|*)
+            COMPREPLY=( $( compgen -W "--help --version --debug --verbose" -- "$cur" ) )
+            return 0
+            ;; 
+    esac
+} &&
+complete -F _puppet -o filenames puppetmasterd puppetd puppetca ralsh puppetrun puppetqd filebucket puppetdoc puppet 
+
+# Local variables:
+# mode: shell-script
+# sh-basic-offset: 4
+# sh-indent-comment: t
+# indent-tabs-mode: nil
+# End:
+# ex: ts=4 sw=4 et filetype=sh

-- 
bash-completion



More information about the Bash-completion-commits mailing list