summaryrefslogtreecommitdiff
path: root/contrib/zsh/_mon.zsh
blob: 3770c6075d1e42e3965dbbc4de317fd2a79c4115 (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
#compdef m mon

get_options() {
    elements=`${words[1,$[${CURRENT}-1]]} --dry --nocolor 2>&1`
    if [ $? -ne 0 ]; then
            elements=""
    fi

    echo `echo $elements | tr '\n' ' '`
}

_mon() { 
    local curcontext="$curcontext" state line
    typeset -A opt_args

    case $words[2] in
    getfmt)
        if [ $CURRENT -eq 5 ]; then
            compadd "$@" "where"
            return
        fi
    ;;
    post|put)
        if [ $CURRENT -eq 4 ]; then
            compadd "$@" "from"
            return
        fi
    ;;
    delete|edit|get|insert|update|view)
        if [ $CURRENT -eq 4 ]; then
            compadd "$@" "where"
            return
        fi
    ;;
    esac

    VALUES="`get_options`"
    if [ -z "${VALUES}" ]; then
        _files
    else
        ARGS=(${=VALUES})
        compadd "$@" ${ARGS[@]}
    fi
}

_mon "$@"