bash-completion.sh
author Dan Winship <danw@gnome.org>
Fri Feb 29 12:45:08 2008 -0500 (2008-02-29)
changeset 138 49deac048d07
parent 54 9e3907688d78
child 187 6ff03223ce4c
permissions -rw-r--r--
implement file dependencies for installs

removes are trickier because there are no backlinks from the files array
the properties array, so there's currently no way to efficiently determine
what packages are affected by the removal of a particular file
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