bash-completion.sh
author Kristian H?gsberg <krh@redhat.com>
Mon Oct 22 22:55:06 2007 -0400 (2007-10-22)
changeset 53 a73c2ac05cbe
child 54 9e3907688d78
permissions -rw-r--r--
Add bash completion script.
krh@53
     1
__razor_commands () {
krh@53
     2
    COMPREPLY=($(compgen -W "list-requires list-provides list-files list-file-packages what-requires what-provides import-yum import-rpmdb validate update diff" -- $1))
krh@53
     3
}
krh@53
     4
krh@53
     5
__razor_packages () {
krh@53
     6
    COMPREPLY=($(compgen -W "$(./razor list)" -- $1))
krh@53
     7
}
krh@53
     8
krh@53
     9
__razor_files() {
krh@53
    10
    COMPREPLY=($(compgen -W "$(./razor list-files)" -- $1))
krh@53
    11
}
krh@53
    12
krh@53
    13
__razor_requires() {
krh@53
    14
    echo requires
krh@53
    15
    COMPREPLY=($(compgen -W "$(./razor list-requires)" -- $1))
krh@53
    16
}
krh@53
    17
krh@53
    18
__razor_provides() {
krh@53
    19
    COMPREPLY=($(compgen -W "$(./razor list-provides)" -- $1))
krh@53
    20
}
krh@53
    21
krh@53
    22
__razor() {
krh@53
    23
    local cur="${COMP_WORDS[COMP_CWORD]}"
krh@53
    24
krh@53
    25
    if [ $COMP_CWORD = 1 ]; then
krh@53
    26
	__razor_commands $cur
krh@53
    27
    else
krh@53
    28
	case "${COMP_WORDS[1]}" in
krh@53
    29
	    list-requires|list-provides) __razor_packages $cur ;;
krh@53
    30
	    list-files|list-file-packages) __razor_files $cur ;;
krh@53
    31
	    what-requires) __razor_requires $cur ;;
krh@53
    32
	    what-provides) __razor_provides $cur ;;
krh@53
    33
	esac
krh@53
    34
    fi
krh@53
    35
}
krh@53
    36
krh@53
    37
complete -F __razor razor