PageRenderTime 57ms CodeModel.GetById 52ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/bash_completion.d/mock

http://github.com/brinkman83/bashrc
#! | 85 lines | 77 code | 8 blank | 0 comment | 0 complexity | b8738aadbcb60e248fe826b26865e435 MD5 | raw file
 1# bash completion for mock
 2
 3have mock &&
 4_mock()
 5{
 6    local cur prev plugins cfgdir split=false
 7
 8    COMPREPLY=()
 9    cur=`_get_cword`
10    prev=${COMP_WORDS[COMP_CWORD-1]}
11    plugins='tmpfs root_cache yum_cache bind_mount ccache'
12    cfgdir=/etc/mock
13
14    count=0
15    for i in "${COMP_WORDS[@]}" ; do
16        [ $count -eq $COMP_CWORD ] && break
17        if [[ "$i" == --configdir ]] ; then
18            cfgdir="${COMP_WORDS[((count+1))]}"
19        elif [[ "$i" == --configdir=* ]] ; then
20            cfgdir=${i/*=/}
21        fi
22        count=$((++count))
23    done
24
25    _split_longopt && split=true
26
27    case $prev in
28        -@(h|-help|-copy@(in|out)|-arch|D|-define|-with?(out)|-uniqueext|-rpmbuild_timeout|-sources|-cwd))
29            return 0
30            ;;
31        -r|--root)
32            COMPREPLY=( $( compgen -W "$( command ls $cfgdir )" -- $cur ) )
33            COMPREPLY=( ${COMPREPLY[@]/%.cfg/} )
34            return 0
35            ;;
36        --@(config|result)dir)
37            _filedir -d
38            return 0
39            ;;
40        --spec)
41            _filedir spec
42            return 0
43            ;;
44        --target)
45            # Yep, compatible archs, not compatible build archs
46            # (e.g. ix86 chroot builds in x86_64 mock host)
47            # This would actually depend on what the target root
48            # can be used to build for...
49            COMPREPLY=( $( compgen -W "$( command rpm --showrc | \
50                sed -ne 's/^\s*compatible\s\+archs\s*:\s*\(.*\)/\1/i p' )" \
51                -- "$cur" ) )
52            return 0
53            ;;
54        --@(en|dis)able-plugin)
55            COMPREPLY=( $( compgen -W "$plugins" -- "$cur" ) )
56            return 0
57            ;;
58    esac
59
60    $split && return 0
61
62    if [[ "$cur" == -* ]] ; then
63        COMPREPLY=( $( compgen -W '--version -h --help --rebuild \
64            --buildsrpm --shell --chroot --clean --init \
65            --installdeps --install --update --orphanskill \
66            --copyin --copyout -r --root --offline --no-clean \
67            --cleanup-after --no-cleanup-after --arch --target \
68            -D --define --with --without --resultdir --uniqueext \
69            --configdir --rpmbuild_timeout --unpriv --cwd --spec \
70            --sources -v --verbose -q --quiet --trace \
71            --enable-plugin --disable-plugin --print-root-path' \
72            -- "$cur" ) )
73    else
74        _filedir '?(no)src.rpm'
75    fi
76} &&
77complete -F _mock $filenames mock
78
79# Local variables:
80# mode: shell-script
81# sh-basic-offset: 4
82# sh-indent-comment: t
83# indent-tabs-mode: nil
84# End:
85# ex: ts=4 sw=4 et filetype=sh