[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.90-72-g56672db

Ville Skyttä ville.skytta at iki.fi
Sat Nov 26 15:46:19 UTC 2011


The following commit has been merged in the master branch:
commit 56672db701da5e5e263090eaf37b4b708db3c63b
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sat Nov 26 17:45:47 2011 +0200

    koji: New completion.

diff --git a/completions/.gitignore b/completions/.gitignore
index 9ce8b5a..6ce1679 100644
--- a/completions/.gitignore
+++ b/completions/.gitignore
@@ -3,6 +3,7 @@ alpine
 alternatives
 animate
 apropos
+arm-koji
 asciidoc.py
 autoheader
 automake-1.11
@@ -104,6 +105,7 @@ pm-suspend
 pm-suspend-hybrid
 pmake
 postalias
+ppc-koji
 puppetca
 puppetd
 puppetdoc
@@ -133,6 +135,7 @@ rpm2targz
 rpm2txz
 rpmbuild
 rpmbuild-md5
+s390-koji
 sbcl-mt
 scp
 sdptool
@@ -145,6 +148,7 @@ smbget
 smbpasswd
 smbtar
 smbtree
+sparc-koji
 spovray
 stream
 tightvncviewer
diff --git a/completions/Makefile.am b/completions/Makefile.am
index 892523b..5b2e68f 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -148,6 +148,7 @@ bashcomp_DATA = a2x \
 		killall \
 		kldload \
 		kldunload \
+		koji \
 		ktutil \
 		larch \
 		lastlog \
@@ -340,6 +341,7 @@ CLEANFILES = \
 	alternatives \
 	animate \
 	apropos \
+	arm-koji \
 	asciidoc.py \
 	autoheader \
 	automake-1.11 \
@@ -441,6 +443,7 @@ CLEANFILES = \
 	pm-suspend-hybrid \
 	pmake \
 	postalias \
+	ppc-koji \
 	puppetca \
 	puppetd \
 	puppetdoc \
@@ -470,6 +473,7 @@ CLEANFILES = \
 	rpm2txz \
 	rpmbuild \
 	rpmbuild-md5 \
+	s390-koji \
 	sbcl-mt \
 	scp \
 	sdptool \
@@ -482,6 +486,7 @@ CLEANFILES = \
 	smbpasswd \
 	smbtar \
 	smbtree \
+	sparc-koji \
 	spovray \
 	stream \
 	tightvncviewer \
@@ -634,6 +639,10 @@ symlinks:
 		rm -f $(targetdir)/$$file && \
 			$(LN_S) killall $(targetdir)/$$file ; \
 	done
+	for file in arm-koji ppc-koji s390-koji sparc-koji ; do \
+		rm -f $(targetdir)/$$file && \
+			$(LN_S) koji $(targetdir)/$$file ; \
+	done
 	for file in ldapadd ldapmodify ldapdelete ldapcompare ldapmodrdn \
 		ldapwhoami ldappasswd ; do \
 		rm -f $(targetdir)/$$file && \
diff --git a/completions/koji b/completions/koji
new file mode 100644
index 0000000..f4bdeac
--- /dev/null
+++ b/completions/koji
@@ -0,0 +1,234 @@
+# koji completion                                          -*- shell-script -*-
+
+_koji_search()
+{
+    COMPREPLY+=( $( compgen -W \
+        '$( "$1" -q search $2 "$cur*" 2>/dev/null )' -- "$cur" ) )
+}
+
+_koji_build()
+{
+    _koji_search "$1" build
+}
+
+_koji_package()
+{
+    _koji_search "$1" package
+}
+
+_koji_user()
+{
+    _koji_search "$1" user
+}
+
+_koji_tag()
+{
+    COMPREPLY+=( $( compgen -W '$( "$1" -q list-tags 2>/dev/null )' \
+        -- "$cur" ) )
+}
+
+_koji_target()
+{
+    COMPREPLY+=( $( compgen -W '$( "$1" -q list-targets 2>/dev/null |
+        awk "{ print \$1 }" )' -- "$cur" ) )
+}
+
+_koji()
+{
+    local cur prev words cword split
+    _init_completion -s || return
+
+    local commandix command
+    for (( commandix=1; commandix < cword; commandix++ )); do
+        if [[ ${words[commandix]} != -* ]]; then
+            command=${words[commandix]}
+            break
+        fi
+    done
+
+    case $prev in
+        -h|--help|--help-commands)
+            return
+            ;;
+        -c|--config|--keytab|-o)
+            _filedir
+            return
+            ;;
+        --runas|--user|--editor|--by)
+            _koji_user "$1"
+            return
+            ;;
+        --authtype)
+            COMPREPLY=( $( compgen -W 'noauth ssl password kerberos' \
+                -- "$cur" ) )
+            return
+            ;;
+        --topdir)
+            _filedir -d
+            return
+            ;;
+        --type)
+            case $command in
+                latest-pkg|list-tagged)
+                    COMPREPLY=( $( compgen -W 'maven' -- "$cur" ) )
+                    ;;
+            esac
+            return
+            ;;
+        --name)
+            case $command in
+                list-targets)
+                    _koji_target "$1"
+                    ;;
+            esac
+            return
+            ;;
+        --owner)
+            _koji_user "$1"
+            return
+            ;;
+        --tag|--latestfrom)
+            _koji_tag "$1"
+            return
+            ;;
+        --package)
+            _koji_package "$1"
+            return
+            ;;
+        --build)
+            _koji_build "$1"
+            return
+            ;;
+        --build-target)
+            _koji_target "$1"
+            return
+            ;;
+    esac
+
+    $split && return
+
+    if [[ $command ]]; then
+        if [[ $cur == -* ]]; then
+            COMPREPLY=( $( compgen -W \
+                '$( _parse_help "$1" "$command --help" )' -- "$cur" ) )
+            [[ $COMPREPLY == *= ]] && compopt -o nospace
+            return
+        fi
+
+        # How many'th non-option arg (1-based) for $command are we completing?
+        local i nth=1
+        for (( i=commandix+1; i < cword; i++ )); do
+            [[ ${words[i]} == -* ]] || (( nth++ ))
+        done
+
+        case $command in
+            build|maven-build|win-build)
+                case $nth in
+                    1)
+                        _koji_target "$1"
+                        ;;
+                    2)
+                        _filedir src.rpm
+                        ;;
+                esac
+                ;;
+            cancel)
+                _koji_build "$1"
+                ;;
+            chain-build)
+                case $nth in
+                    1)
+                        _koji_target "$1"
+                        ;;
+                esac
+                ;;
+            download-build)
+                case $nth in
+                    1)
+                        _koji_build "$1"
+                        ;;
+                esac
+                ;;
+            import-comps)
+                case $nth in
+                    1)
+                        _filedir xml
+                        ;;
+                    2)
+                        _koji_tag "$1"
+                        ;;
+                esac
+                ;;
+            latest-by-tag)
+                _koji_package "$1"
+                ;;
+            latest-pkg|list-groups|list-tag-inheritance|show-groups|wait-repo)
+                case $nth in
+                    1)
+                        _koji_tag "$1"
+                        ;;
+                esac
+                ;;
+            list-tagged)
+                case $nth in
+                    1)
+                        _koji_tag "$1"
+                        ;;
+                    2)
+                        _koji_package "$1"
+                        ;;
+                esac
+                ;;
+            list-untagged)
+                case $nth in
+                    1)
+                        _koji_package "$1"
+                        ;;
+                esac
+                ;;
+            move-pkg)
+                case $nth in
+                    1|2)
+                        _koji_tag "$1"
+                        ;;
+                    *)
+                        _koji_package "$1"
+                        ;;
+                esac
+                ;;
+            search)
+                case $nth in
+                    1)
+                        COMPREPLY=( $( compgen -W 'package build tag target
+                            user host rpm' -- "$cur" ) )
+                        ;;
+                esac
+                ;;
+            tag-pkg|untag-pkg)
+                case $nth in
+                    1)
+                        _koji_tag "$1"
+                        ;;
+                    *)
+                        _koji_package "$1"
+                        ;;
+                esac
+                ;;
+            taginfo)
+                _koji_tag "$1"
+                ;;
+        esac
+        return
+    fi
+
+    if [[ $cur == -* ]]; then
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+        [[ $COMPREPLY == *= ]] && compopt -o nospace
+    elif [[ ! $command ]]; then
+        COMPREPLY=( $( compgen -W '$( "$1" --help-commands 2>/dev/null | \
+            awk "/^(  +|\t)/ { print \$1 }" )' -- "$cur" ) )
+    fi
+} &&
+complete -F _koji koji arm-koji ppc-koji s390-koji sparc-koji
+
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/test/completion/koji.exp b/test/completion/koji.exp
new file mode 100644
index 0000000..4d85dfc
--- /dev/null
+++ b/test/completion/koji.exp
@@ -0,0 +1 @@
+assert_source_completions koji
diff --git a/test/lib/completions/lsof.exp b/test/lib/completions/koji.exp
similarity index 69%
copy from test/lib/completions/lsof.exp
copy to test/lib/completions/koji.exp
index 551bde2..a967380 100644
--- a/test/lib/completions/lsof.exp
+++ b/test/lib/completions/koji.exp
@@ -11,10 +11,11 @@ proc teardown {} {
 setup
 
 
-assert_complete_any "lsof "
+assert_complete_any "koji "
 sync_after_int
 
-assert_complete_any "lsof -"
+
+assert_complete_any "koji -"
 sync_after_int
 
 

-- 
bash-completion



More information about the Bash-completion-commits mailing list