aboutsummaryrefslogtreecommitdiff
path: root/bash-completion/inquisitio
blob: 953c95db9cbd0b457bd37c6766087477c93e526e (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Bash completion function for inquisitio
# Written by Mike Kelly
# vim: set et sw=4 sts=4 ts=4 ft=sh :

# NOTE: This is still a work in progress, don't expect it to work well or
# properly right now.

_inquisitio() {
    local cur prev opts
    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}

    opts="--search -s \
        --version -V \
        --help -h \
        --log-level \
        --no-colour \
        --no-color \
        --environment -E \
        --keys -k \
        --matcher -m \
        --flatten -f \
        --enabled-only -e \
        --not -n \
        --repository -r \
        --repository-format \
        --category \
        --package \
        --visible-only -v \
        --all-versions -a \
        --kind -K \
        --compact \
        --no-compact \
        --show-dependencies -D \
        --show-metadata -M"

    case "${cur}" in
        -*)
            COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
            return 0
            ;;
        *)
            case "${prev}" in
                ## Enum operators
                --log-level)
                    COMPREPLY=($(compgen -W "debug qa warning silent" -- "${cur}"))
                    return 0
                    ;;

                --matcher|-m)
                    COMPREPLY=($(compgen -W "text pcre exact" -- "${cur}"))
                    return 0
                    ;;

                --repository|-r)
                    COMPREPLY=($(compgen -W "$(paludis --log-level silent --list-repositories |sed -n 's,^\* \(.*\),\1,p')" -- "${cur}"))
                    return 0
                    ;;
                --repository-format)
                    COMPREPLY=($(compgen -W "$(paludis --log-level silent --list-repository-formats |sed -n 's,^\* \(.*\),\1,p')" -- "${cur}"))
                    return 0
                    ;;
                --category)
                    COMPREPLY=($(compgen -W "$(paludis --log-level silent --list-categories |sed -n 's,^\* \(.*\),\1,p')" -- "${cur}"))
                    return 0
                    ;;
                --kind|-K)
                    COMPREPLY=($(compgen -W "installable installed all" -- "${cur}"))
                    return 0
                    ;;

            esac
            ;;
    esac
}
complete -F _inquisitio inquisitio