data/bash-completion.sh
author Kristian H?gsberg <krh@redhat.com>
Fri Jun 20 21:56:43 2008 -0400 (2008-06-20)
changeset 254 ccb1c11968ab
child 258 29d5002bd17f
permissions -rw-r--r--
Introduce install/remove iterators.

These iterator constructors lets you pass in two sets and creates
an iterator for the packages to remove or the packages to install.
The iterators will step through the packages in a sequence that respects
the pre, post, preun and postun modifiers.

Right now, the install order isn't actually implemented, this patch just
implements the API changes and updates the applications.
rhughes@241
     1
__razor_commands () {
rhughes@241
     2
    local IFS=$'\n'
rhughes@241
     3
    COMPREPLY=($(IFS=: compgen -S' ' -W "list-requires:list-provides:list-files:list-file-packages:list-package-files:what-requires:what-provides:import-yum:import-rpmdb:validate:update:diff:install:init:download" -- $1))
rhughes@241
     4
}
rhughes@241
     5
rhughes@241
     6
__razor_packages () {
rhughes@241
     7
    local IFS=$'\n'
rhughes@241
     8
rhughes@241
     9
    COMPREPLY=($(./razor list --only-names "$1*" | while read p; do echo "$p "; done))
rhughes@241
    10
}
rhughes@241
    11
rhughes@241
    12
__razor_upstream_packages () {
rhughes@241
    13
    local IFS=$'\n'
rhughes@241
    14
rhughes@241
    15
    COMPREPLY=($(RAZOR_REPO=rawhide.repo ./razor list --only-names "$1*" | while read p; do echo "$p "; done))
rhughes@241
    16
}
rhughes@241
    17
rhughes@241
    18
__razor_files() {
rhughes@241
    19
    COMPREPLY=($(./razor list-files "$1*"))
rhughes@241
    20
}
rhughes@241
    21
rhughes@241
    22
__razor_requires() {
rhughes@241
    23
    COMPREPLY=($(compgen -W "$(./razor list-requires)" -- $1))
rhughes@241
    24
}
rhughes@241
    25
rhughes@241
    26
__razor_provides() {
rhughes@241
    27
    COMPREPLY=($(compgen -W "$(./razor list-provides)" -- $1))
rhughes@241
    28
}
rhughes@241
    29
rhughes@241
    30
__razor() {
rhughes@241
    31
    local cur="${COMP_WORDS[COMP_CWORD]}"
rhughes@241
    32
rhughes@241
    33
    if [ $COMP_CWORD = 1 ]; then
rhughes@241
    34
	__razor_commands $cur
rhughes@241
    35
    else
rhughes@241
    36
	case "${COMP_WORDS[1]}" in
rhughes@241
    37
	    list-requires|list-provides|list-package-files)
rhughes@241
    38
		__razor_packages $cur ;;
rhughes@241
    39
	    list-files|list-file-packages) __razor_files $cur ;;
rhughes@241
    40
	    what-requires) __razor_requires $cur ;;
rhughes@241
    41
	    what-provides) __razor_provides $cur ;;
rhughes@241
    42
	    install|download) __razor_upstream_packages $cur ;;
rhughes@241
    43
	esac
rhughes@241
    44
    fi
rhughes@241
    45
}
rhughes@241
    46
rhughes@241
    47
complete -o nospace -F __razor razor