aboutsummaryrefslogtreecommitdiff
path: root/bash-completion/reconcilio
blob: c3686864b0656fdb70ae24197a029085c1fba9ff (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# Bash completion function for reconcilio
# 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.

_reconcilio() {
    local cur prev opts

    local action_opts general_opts deplist_opts
    local linkage_opts install_opts all_opts

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

    action_opts="--fix-linkage \
        --version -V \
        --help -h"
    general_opts="--log-level \
        --no-colour \
        --no-color \
        --environment -E \
        --exact \
        --verbose -v \
        --resume-command-template \
        --compact"
    deplist_opts="--dl-reinstall \
        --dl-reinstall-scm \
        --dl-upgrade \
        --dl-new-slots \
        --dl-downgrade \
        --dl-deps-default \
        --dl-installed-deps-pre \
        --dl-installed-deps-runtime \
        --dl-installed-deps-post \
        --dl-uninstalled-deps-pre \
        --dl-uninstalled-deps-runtime \
        --dl-uninstalled-deps-post \
        --dl-uninstalled-deps-suggested \
        --dl-suggested \
        --dl-circular \
        --dl-blocks \
        --dl-override-masks \
        --dl-fall-back"
    install_opts="--pretend -p \
        --no-config-protection \
        --debug-build \
        --checks \
        --fetch -f \
        --no-safe-resume \
        --show-reasons \
        --show-use-descriptions \
        --show-package-descriptions \
        --continue-on-failure \
        ${deplist_opts}"
    linkage_opts="--library \
        ${install_opts}"

    all_opts="${action_opts} ${general_opts} ${linkage_opts} ${install_opts} ${deplist_opts}"

    local x
    for x in "${COMP_WORDS[@]}" ; do
        case "${x}" in
            --fix-linkage)
                action="linkage"
                break
                ;;
            --version|-V|--help|-h)
                action="info"
                break
                ;;
        esac
    done

    case "${cur}" in
        -*)
            local opts=
            [[ -z "${action}" ]] && action="all"
            opts="${action}_opts"

            COMPREPLY=($(compgen -W "${general_opts} ${!opts}" -- "${cur}"))
            return 0
            ;;
        *)
            case "${prev}" in
                ## Enum operators
                --log-level)
                    COMPREPLY=($(compgen -W "debug qa warning silent" -- "${cur}"))
                    return 0
                    ;;
                --debug-build)
                    COMPREPLY=($(compgen -W "none split internal" -- "${cur}"))
                    return 0
                    ;;
                --checks)
                    COMPREPLY=($(compgen -W "none default always" -- "${cur}"))
                    return 0
                    ;;
                --show-reasons)
                    COMPREPLY=($(compgen -W "none summary full" -- "${cur}"))
                    return 0
                    ;;
                --show-use-descriptions)
                    COMPREPLY=($(compgen -W "none new changed all" -- "${cur}"))
                    return 0
                    ;;
                --show-package-descriptions)
                    COMPREPLY=($(compgen -W "none new all" -- "${cur}"))
                    return 0
                    ;;
                --continue-on-failure)
                    COMPREPLY=($(compgen -W "if-fetch-only never if-satisfied if-independent always" -- "${cur}"))
                    return 0
                    ;;

                --dl-reinstall)
                    COMPREPLY=($(compgen -W "never always if-use-changed" -- "${cur}"))
                    return 0
                    ;;
                --dl-reinstall-scm)
                    COMPREPLY=($(compgen -W "never always daily weekly" -- "${cur}"))
                    return 0
                    ;;
                --dl-upgrade)
                    COMPREPLY=($(compgen -W "always as-needed" -- "${cur}"))
                    return 0
                    ;;
                --dl-new-slots)
                    COMPREPLY=($(compgen -W "always as-needed" -- "${cur}"))
                    return 0
                    ;;
                --dl-downgrade)
                    COMPREPLY=($(compgen -W "as-needed warning error" -- "${cur}"))
                    return 0
                    ;;
                --dl-deps-default|--dl-installed-deps-pre|--dl-installed-deps-runtime|--dl-installed-deps-post|--dl-uninstalled-deps-pre|--dl-uninstalled-deps-runtime|--dl-uninstalled-deps-post|--dl-uninstalled-deps-suggested)
                    COMPREPLY=($(compgen -W "pre pre-or-post post try-post discard" -- "${cur}"))
                    return 0
                    ;;

                --dl-suggested)
                    COMPREPLY=($(compgen -W "show install discard" -- "${cur}"))
                    return 0
                    ;;
                --dl-circular)
                    COMPREPLY=($(compgen -W "error discard" -- "${cur}"))
                    return 0
                    ;;
                --dl-blocks)
                    COMPREPLY=($(compgen -W "accumulate error discard" -- "${cur}"))
                    return 0
                    ;;
                --dl-override-masks)
                    COMPREPLY=($(compgen -W "none tilde-keyword unkeyworded repository license" -- "${cur}"))
                    return 0
                    ;;
                --dl-fall-back)
                    COMPREPLY=($(compgen -W "as-needed-except-targets as-needed never" -- "${cur}"))
                    return 0
                    ;;
                *)
                    case "${action}" in
                        --fix-linkage)
                            return 0
                            ;;
                    esac
                    ;;
            esac
            ;;
    esac
}
complete -F _reconcilio reconcilio