_spring 593 Bytes
Newer Older
linux_china's avatar
linux_china committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#compdef spring 'spring'
#autoload

_spring() {

        local cword
        let cword=CURRENT-1

        local hints
        hints=()

        local reply
        while read -r line; do
                reply=`echo "$line" | awk '{printf $1 ":"; for (i=2; i<NF; i++) printf $i " "; print $NF}'`
                hints+=("$reply")
        done < <(spring hint ${cword} ${words[*]})

        if ((cword == 1)) {
                _describe -t commands 'commands' hints
                return 0
        }

        _describe -t options 'options' hints
        _files

        return 0
}

_spring "$@"