bash-completion.sh
author Kristian H?gsberg <krh@redhat.com>
Sun Apr 06 19:24:07 2008 -0400 (2008-04-06)
changeset 190 d8b7dd11813d
parent 56 9c00581c71be
child 194 6d25d2fa0935
permissions -rw-r--r--
Hide a bunch of depsolver internals in razor.c.
krh@53
     1
__razor_commands () {
krh@54
     2
    local IFS=$'\n'
krh@187
     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))
krh@53
     4
}
krh@53
     5
krh@53
     6
__razor_packages () {
krh@54
     7
    local IFS=$'\n'
krh@54
     8
krh@187
     9
    COMPREPLY=($(./razor list --only-names "$1*" | while read p; do echo "$p "; done))
krh@187
    10
}
krh@187
    11
krh@187
    12
__razor_upstream_packages () {
krh@187
    13
    local IFS=$'\n'
krh@187
    14
krh@187
    15
    COMPREPLY=($(RAZOR_REPO=rawhide.repo ./razor list --only-names "$1*" | while read p; do echo "$p "; done))
krh@53
    16
}
krh@53
    17
krh@53
    18
__razor_files() {
krh@54
    19
    COMPREPLY=($(./razor list-files "$1*"))
krh@53
    20
}
krh@53
    21
krh@53
    22
__razor_requires() {
krh@53
    23
    COMPREPLY=($(compgen -W "$(./razor list-requires)" -- $1))
krh@53
    24
}
krh@53
    25
krh@53
    26
__razor_provides() {
krh@53
    27
    COMPREPLY=($(compgen -W "$(./razor list-provides)" -- $1))
krh@53
    28
}
krh@53
    29
krh@53
    30
__razor() {
krh@53
    31
    local cur="${COMP_WORDS[COMP_CWORD]}"
krh@53
    32
krh@53
    33
    if [ $COMP_CWORD = 1 ]; then
krh@53
    34
	__razor_commands $cur
krh@53
    35
    else
krh@53
    36
	case "${COMP_WORDS[1]}" in
krh@56
    37
	    list-requires|list-provides|list-package-files)
krh@56
    38
		__razor_packages $cur ;;
krh@53
    39
	    list-files|list-file-packages) __razor_files $cur ;;
krh@53
    40
	    what-requires) __razor_requires $cur ;;
krh@53
    41
	    what-provides) __razor_provides $cur ;;
krh@187
    42
	    download) __razor_upstream_packages $cur ;;
krh@53
    43
	esac
krh@53
    44
    fi
krh@53
    45
}
krh@53
    46
krh@54
    47
complete -o nospace -F __razor razor