summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2011-11-26 17:45:47 +0200
committerVille Skyttä <ville.skytta@iki.fi>2011-11-26 17:45:47 +0200
commit56672db701da5e5e263090eaf37b4b708db3c63b (patch)
treebc2bc7c458b391b19243cad2b1e48e0550e0ce72
parentbb02bcde80f58cd307a1724b2968292547edcd52 (diff)
downloadbash-completion-56672db701da5e5e263090eaf37b4b708db3c63b.tar.gz
koji: New completion.
-rw-r--r--completions/.gitignore4
-rw-r--r--completions/Makefile.am9
-rw-r--r--completions/koji234
-rw-r--r--test/completion/koji.exp1
-rw-r--r--test/lib/completions/koji.exp22
5 files changed, 270 insertions, 0 deletions
diff --git a/completions/.gitignore b/completions/.gitignore
index 9ce8b5a4..6ce16797 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 892523bc..5b2e68ff 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 00000000..f4bdeacf
--- /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 00000000..4d85dfc2
--- /dev/null
+++ b/test/completion/koji.exp
@@ -0,0 +1 @@
+assert_source_completions koji
diff --git a/test/lib/completions/koji.exp b/test/lib/completions/koji.exp
new file mode 100644
index 00000000..a9673807
--- /dev/null
+++ b/test/lib/completions/koji.exp
@@ -0,0 +1,22 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "koji "
+sync_after_int
+
+
+assert_complete_any "koji -"
+sync_after_int
+
+
+teardown