bash-completion.sh
author Dan Winship <danw@gnome.org>
Fri Mar 14 10:18:58 2008 -0400 (2008-03-14)
changeset 179 a6dfb81e3484
parent 54 9e3907688d78
child 187 6ff03223ce4c
permissions -rw-r--r--
spell out the depsolving rules explicitly, separate from the algorithm
krh@53
     1
__razor_commands () {
krh@54
     2
    local IFS=$'\n'
krh@56
     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" -- $1))
krh@53
     4
}
krh@53
     5
krh@53
     6
__razor_packages () {
krh@54
     7
    local IFS=$'\n'
krh@54
     8
krh@54
     9
    COMPREPLY=($(./razor list "$1*" | while read p; do echo "$p "; done))
krh@53
    10
}
krh@53
    11
krh@53
    12
__razor_files() {
krh@54
    13
    COMPREPLY=($(./razor list-files "$1*"))
krh@53
    14
}
krh@53
    15
krh@53
    16
__razor_requires() {
krh@53
    17
    COMPREPLY=($(compgen -W "$(./razor list-requires)" -- $1))
krh@53
    18
}
krh@53
    19
krh@53
    20
__razor_provides() {
krh@53
    21
    COMPREPLY=($(compgen -W "$(./razor list-provides)" -- $1))
krh@53
    22
}
krh@53
    23
krh@53
    24
__razor() {
krh@53
    25
    local cur="${COMP_WORDS[COMP_CWORD]}"
krh@53
    26
krh@53
    27
    if [ $COMP_CWORD = 1 ]; then
krh@53
    28
	__razor_commands $cur
krh@53
    29
    else
krh@53
    30
	case "${COMP_WORDS[1]}" in
krh@56
    31
	    list-requires|list-provides|list-package-files)
krh@56
    32
		__razor_packages $cur ;;
krh@53
    33
	    list-files|list-file-packages) __razor_files $cur ;;
krh@53
    34
	    what-requires) __razor_requires $cur ;;
krh@53
    35
	    what-provides) __razor_provides $cur ;;
krh@53
    36
	esac
krh@53
    37
    fi
krh@53
    38
}
krh@53
    39
krh@54
    40
complete -o nospace -F __razor razor