summaryrefslogtreecommitdiff
path: root/priv/shell-completion/bash/rebar
blob: f57ac0e2a2e6710a2ae111261eed009271bd357a (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# bash completion for rebar

_rebar()
{
    local cur prev sopts lopts cmdsnvars
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    sopts="-h -v -f -j"
    lopts=" --help --verbose --force --jobs="
    cmdsnvars="analyze build_plt check_plt clean compile \
        create-app create-node eunit generate \
        int_test perf_test test \
        case= force=1 jobs= suite= verbose=1"

    if [[ ${cur} == --* ]] ; then
        COMPREPLY=( $(compgen -W "${lopts}" -- ${cur}) )
        if [ -n "$COMPREPLY" ] ; then
            # append space if matched
            COMPREPLY="${COMPREPLY} "
            # remove trailing space if --lopt=value option
            COMPREPLY=${COMPREPLY/%= /=}
        fi
        return 0
    elif [[ ${cur} == -* ]] ; then
        COMPREPLY=( $(compgen -W "${sopts}" -- ${cur}) )
        if [ -n "$COMPREPLY" ] ; then
            # append space if matched
            COMPREPLY="${COMPREPLY} "
        fi
        return 0
    else
        COMPREPLY=( $(compgen -W "${cmdsnvars}" -- ${cur}) )
        if [ -n "$COMPREPLY" ] ; then
            # append space if matched
            COMPREPLY="${COMPREPLY} "
            # remove trailing space if var= option
            COMPREPLY=${COMPREPLY/%= /=}
        fi
        return 0
    fi
}
complete -o nospace -F _rebar rebar

# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh