aboutsummaryrefslogtreecommitdiff
path: root/zsh-completion/_cave
blob: 27b67c1298b7bbc037825cf395fbf316c464699c (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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#compdef cave

# vim: set et sw=2 sts=2 ts=2 ft=zsh :
# ZSH completion for `cave`
# Written by Ingmar Vanhassel <ingmar@exherbo.org>

_cave()
{
  local -a _cave_arguments _cave_commands
  local cmd

  _cave_arguments=(
    '(-E --environment)'{-E,--environment}'[Environment specification]:environment specification: '
    '--log-level[Specify the log level]:log level:((debug\:"Show debug output (noisy)"
                                                    qa\:"Show QA messages and warnings only (default)"
                                                    warning\:"Show warnings only"
                                                    silent\:"Suppress all log messages (UNSAFE)"))'
  )

  _cave_commands=(
    'help:Display help information for a particular command'
    'perform:Perform an action upon a package'
    'print-categories:Prints a list of known categories'
    'print-commands:Prints a list of known cave commands'
    'print-environment-metadata:Prints environment metadata'
    'print-id-contents:Prints the contents of a package ID'
    'print-id-executables:Prints a list of executables belonging to an ID'
    'print-id-metadata:Prints ID metadata'
    'print-ids:Prints a list of known IDs'
    'print-owners:Prints a list of package IDs owning a given file'
    'print-packages:Prints a list of package names'
    'print-repositories:Prints a list of repositories'
    'print-sets:Prints a list of sets'
    'print-sync-protocols:Prints a list of sync protocols'
    'resolve:Display how to resolve targets and optionally perform that resolution'
    'show:Displays a formatted summary of a given object'
    'sync:Sync all or specified repositories'
    'update-world:Update the world set'
  )

  for (( i=1; i <= ${CURRENT}; i++ )); do
    cmd=${_cave_commands[(r)${words[${i}]}:*]%%:*}
    (( ${#cmd} )) && break
  done

  if (( ${#cmd} )); then
    local curcontext="${curcontext%:*:*}:cave-${cmd}:"

    while [[ ${words[1]} != ${cmd} ]]; do
      (( CURRENT-- ))
      shift words
    done

    _call_function ret _cave_cmd_${cmd}
    return ret
  else
    if [[ ${words[CURRENT-1]} == --* ]]; then
      _arguments -s : \
        ${_cave_arguments}
    else
      _describe -t commands 'cave command' _cave_commands
      _arguments -s : \
        ${_cave_arguments}
    fi
  fi

}

(( ${+functions[_cave_cmd_help]} )) ||
_cave_cmd_help()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '*::arg:->cave_commands' && return

  case ${state} in
    (cave_commands)
      _describe -t commands 'cave command' _cave_commands
      ;;
  esac
}

(( ${+functions[_cave_cmd_perform]} )) ||
_cave_cmd_perform()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '(--if-supported --no-if-supported)'{--if-supported,--no-if-supported}'[Exit with success rather than erroring, if the action is not supported]' \
    '(--hooks --no-hooks)'{--hooks,--no-hooks}'[Execute appropriate hooks for the action]'
}

(( ${+functions[_cave_cmd_print-categories]} )) ||
_cave_cmd_print-categories()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '--containing[Show only categories containing this package name]:package name: ' \
    '--repository[Show only categories in this repository]:repository name: '
}

(( ${+functions[_cave_cmd_print-commands]} )) ||
_cave_cmd_print-commands()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]'
}

(( ${+functions[_cave_cmd_print-environment-metadata]} )) ||
_cave_cmd_print-environment-metadata()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '--raw-name[Show only keys with this raw name]:raw name: ' \
    '--human-name[Show only keys with this human name]:human name: ' \
    '--format[Select the output format]:format: '
}

(( ${+functions[_cave_cmd_print-id-contents]} )) ||
_cave_cmd_print-id-contents()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '--best[If the spec matches multiple IDs, select the best ID rather than giving an error]' \
    '--nobest[If the spec matches multiple IDs, give an error]' \
    '--format[Select the output format]:format: ' \
    '*:package depspec:_cave_packages' && return 0
}

(( ${+functions[_cave_cmd_print-id-executables]} )) ||
_cave_cmd_print-id-executables()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '*:package depspec:_cave_packages' && return 0
}


(( ${+functions[_cave_cmd_print-id-metadata]} )) ||
_cave_cmd_print-id-metadata()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '--best[If the spec matches multiple IDs, select the best ID rather than giving an error]' \
    '--nobest[If the spec matches multiple IDs, give an error]' \
    '--raw-name[Show only keys with this raw name]:raw name: ' \
    '--human-name[Show only keys with this human name]:human name: ' \
    '--format[Select the output format]:output format: ' \
    '*:package depspec:_cave_packages' && return 0
}

(( ${+functions[_cave_cmd_print-ids]} )) ||
_cave_cmd_print-ids()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '--matching[Show only IDs matching this spec]:package spec: ' \
    '--supporting[Show only IDs supporting this action]:supporting action:((install uninstall pretend config fetch pretend-fetch info))' \
    '--with-mask[Show only IDs with this kind of mask]:with mask:((none any user unaccepted repository unsupported association))'
}

(( ${+functions[_cave_cmd_print-owners]} )) ||
_cave_cmd_print-owners()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '(--match -m)'{--match,-m}'[Which match algorithm to use]:match algorithm:((auto\:"If pattern starts with a \/, full; if it contains a \/, partial; otherwise, basename (default)"
                                                                                basename\:"Basename match"
                                                                                full\:"Full match"
                                                                                partial\:"Partial match"))' \
    '*:file:_files'
}

(( ${+functions[_cave_cmd_print-packages]} )) ||
_cave_cmd_print-packages()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]'
}


(( ${+functions[_cave_cmd_print-repositories]} )) ||
_cave_cmd_print-repositories()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '--format[Show only repositories of a specific format]:repository format: '
}

(( ${+functions[_cave_cmd_resolve]} )) ||
_cave_cmd_resolve()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '(--execute -x)'{--execute,-x}'[Execute resolution]' \
    '(--lazy -z --complete -c --everything -e --no-lazy --no-complete --no-everything)'{--lazy,-z,--no-lazy}'[Do as little work as possible]' \
    '(--lazy -z --complete -c --everything -e --no-lazy --no-complete --no-everything)'{--complete,-c,--no-complete}'[Do all optional work]' \
    '(--lazy -z --complete -c --everything -e --no-lazy --no-complete --no-everything)'{--everything,-e,--no-everything}'[Do all optional work, and also reinstall]' \
    '--explain[Explain why decisions are made]:package depspec: ' \
    '(--keep-targets -K)'{--keep-targets,-K}'[Select whether to keep target packages]:When:((auto never if-transient if-same if-same-version if-possible))' \
    '(--keep -k)'{--keep,-k}'[Select whether to keep packages that are not targets]:When:((never if-transient if-same if-same-version if-possible))' \
    '(--reinstall-scm -R)'{--reinstall-scm,-R}'[Select whether to reinstall SCM packages that would otherwise be kept]:When:((always daily weekly never))' \
    '(--target-slots -S)'{--target-slots,-S}'[Which slots to consider for targets]:Which:((best-or-installed installed-or-best all best))' \
    '(--slots -s)'{--slots,-s}'[Which slots to consider for packages that are not targets]:Which:((best-or-installed installed-or-best all best))' \
    '(--follow-installed-build-dependencies --no-follow-installed-build-dependencies -D)'{--follow-installed-build-dependencies,--no-follow-installed-build-dependencies,-D}'[Follow build dependencies for installed packages]' \
    '(--ignore-installed-dependencies --no-ignore-installed-dependencies -d)'{--ignore-installed-dependencies,--no-ignore-installed-dependencies,-d}'[Ignore dependencies for installed packages]' \
    '(--dump --no-dump)'{--dump,--no-dump}'[Dump debug output]' \
    '(--dump-dependencies --no-dump-dependencies)'{--dump-dependencies,--no-dump-dependencies}'[Dump the sanitised dependencies selected for every package]' \
    '(--dump-restarts --no-dump-restarts)'{--dump-restarts,--no-dump-restarts}'[Dump restarts]' \
    '(--create-binaries -b)'{--create-binaries,-b}'[Create binary packages in the specified repository]:Repository: ' \
    '(--no-binaries-for -B)'{--no-binaries-for,-B}'[Do not create binary packages from any origin ID matching a spec]:Spec: ' \
    '(--install-to-root -/ --no-install-to-root)'{--install-to-root,-/,--no-install-to-root}'[Install packages to /]' \
    '(--preserve-world -1 --no-preserve-world)'{--preserve-world,-1,--no-preserve-world}'[Do not modify the world set]' \
    '--continue-on-failure[Whether to continue after an error occurs]:When:((if-fetching never if-satisfied if-independent always))' \
    '--skip-phase[Skip the named phases]:Phase: ' \
    '--abort-at-phase[Abort when a named phase is encountered]:Phase: ' \
    '--skip-until-phase[Skip every phase until a named phase is encountered]:Phase: ' \
    '--change-phases-for[Control to which packages these phase options apply]:Which:((all first last))' \
    '--show-descriptions[Whether to display package descriptions]:When:((none new all))' \
    '*:package depspec:_cave_packages' && return 0
}

(( ${+functions[_cave_cmd_show]} )) ||
_cave_cmd_show()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '--type[Specify the type of the specified objects]:object type:((auto repository set wildcard package))' \
    '(--complex-keys -c)'{--complex-keys,-c}'[Show complex keys]' \
    '(--internal-keys -i)'{--internal-keys,-i}'[Show keys regardless of importance, including internal-only values]' \
    '(--flat -f)'{--flat,-f}'[Do not spread key values over multiple lines]' \
    '*:package depspec:_cave_packages' && return 0
}

(( ${+functions[_cave_cmd_sync]} )) ||
_cave_cmd_sync()
{
  # TODO: Complete repository names
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]'
}

(( ${+functions[_cave_cmd_update-world]} )) ||
_cave_cmd_update-world()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '(--remove --no-remove -r)'{--remove,--no-remove,-r}'[Remove the specified items]' \
    '(--set --no-set -s)'{--set,--no-set,-s}'[Parameters are set names, not package names]' \
    '*:package depspec:_cave_packages' && return 0
}

(( ${+functions[_cave_packages]} )) ||
_cave_packages() {
  :
}

_cave "${@}"