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
     1 __razor_commands () {
     2     local IFS=$'\n'
     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))
     4 }
     5 
     6 __razor_packages () {
     7     local IFS=$'\n'
     8 
     9     COMPREPLY=($(./razor list "$1*" | while read p; do echo "$p "; done))
    10 }
    11 
    12 __razor_files() {
    13     COMPREPLY=($(./razor list-files "$1*"))
    14 }
    15 
    16 __razor_requires() {
    17     COMPREPLY=($(compgen -W "$(./razor list-requires)" -- $1))
    18 }
    19 
    20 __razor_provides() {
    21     COMPREPLY=($(compgen -W "$(./razor list-provides)" -- $1))
    22 }
    23 
    24 __razor() {
    25     local cur="${COMP_WORDS[COMP_CWORD]}"
    26 
    27     if [ $COMP_CWORD = 1 ]; then
    28 	__razor_commands $cur
    29     else
    30 	case "${COMP_WORDS[1]}" in
    31 	    list-requires|list-provides|list-package-files)
    32 		__razor_packages $cur ;;
    33 	    list-files|list-file-packages) __razor_files $cur ;;
    34 	    what-requires) __razor_requires $cur ;;
    35 	    what-provides) __razor_provides $cur ;;
    36 	esac
    37     fi
    38 }
    39 
    40 complete -o nospace -F __razor razor