aboutsummaryrefslogtreecommitdiff
path: root/zsh-completion/_cave
blob: c11bc85ce0d0dcda490cf403838b724310ceef14 (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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
#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=(
    'config:Perform post-install configuration on a package'
    'fix-cache:Fix on-disk caches'
    'fix-linkage:Identify packages with broken linkage that can be fixed by rebuilds'
    'help:Display help information for a particular command'
    'info:Display a summary of configuration and package information'
    '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'
    'search:Search for packages with particular characteristics'
    '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_config]} )) ||
_cave_cmd_config()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]'
}

(( ${+functions[_cave_cmd_fix-cache]} )) ||
_cave_cmd_fix-cache()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '*'{--repository,-r}'[Select the repository with the specified name]:repository name:_cave_repositories' \
    '(--installable -i --no-installable)'{--installable,-i,--no-installable}'[Select all installable repositories]' \
    '(--installed -I --no-installed)'{--installed,-I,--no-installed}'[Select all installed repositories]'
}

(( ${+functions[_cave_cmd_fix-linkage]} )) ||
_cave_cmd_fix-linkage()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '(--execute -x)'{--execute,-x}'[Execute resolution]' \
    '--library[Only rebuild packages linked against this library, even if it exists]:Library: ' \
    '--exact[Rebuild the same package version that is currently installed]'
}

(( ${+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_info]} )) ||
_cave_cmd_info()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]'
}

(( ${+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]' \
    '--x-of-y[Set the value of the X_OF_Y variable that is passed to hooks]:value: ' \
    '(--background --no-background)'{--background,--no-background}'[Indicate that we are being run in the background]' \
    ':subcommand:->subcommand' \
    '*::options:->options' && ret=0

    case ${state} in
      (subcommand)
        declare -a subcommand
        subcommand=(
          'config'
          'fetch'
          'info'
          'install'
          'pretend'
          'pretend-fetch'
          'uninstall'
        )

        _describe -t subcommand command subcommand && ret=0
        ;;
      (options)
        declare -a arguments

        case ${line[1]} in
          config|info)
            _arguments -s : \
              '*:package depspec:_cave_packages' && ret=0
            ;;
          fetch|pretend-fetch)
            _arguments -s : \
              '(--exclude-unmirrorable --no-exclude-unmirrorable)'{--exclude-unmirrorable,--no-exclude-unmirrorable}'[Do not include unmirrorable components]' \
              '(--fetch-unneeded --no-fetch-unneeded)'{--fetch-unneeded,--no-fetch-unneeded}'[Fetch components that aren'\''t needed]' \
              '(--ignore-unfetched --no-ignore-unfetched)'{--ignore-unfetched,--no-ignore-unfetched}'[Only verify components that have already been downloaded]' \
              '(--regulars-only --no-regulars-only)'{--regulars-only,--no-regulars-only}'[Only fetch regular components]' \
              '*:package depspec:_cave_packages' && ret=0
            ;;
          install|pretend)
            _arguments -s : \
              '--destination[Repository to which the install should take place]:repository name:_cave_repositories' \
              '--replacing[Spec uniquely identifying the ID to be replaced]:package spec: ' \
              '*--skip-phase[Skip the named phases]:phase:((fetch_extra killold init setup unpack prepare configure compile test test_expensive install strip preinst merge prerm postrm postinst tidyup))' \
              '*--abort-at-phase[Abort when a named phase is encountered]:phase:((fetch_extra killold init setup unpack prepare configure compile test test_expensive install strip preinst merge prerm postrm postinst tidyup))' \
              '*--skip-until-phase[Skip every phase until a named phase is encountered]:phase:((fetch_extra killold init setup unpack prepare configure compile test test_expensive install strip preinst merge prerm postrm postinst tidyup))' \
              '*:package depspec:_cave_packages' && ret=0
            ;;
          uninstall)
            _arguments -s : \
              '*--config-protect[Specify additional items to include in the config protection list]:file:_files' \
              '*:package depspec:_cave_packages' && ret=0
            ;;
        esac
        ;;
    esac
}

(( ${+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:_cave_repositories'
}

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

(( ${+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 -X)'{--explain,-X}'[Explain why decisions are made]:Spec: ' \
    '*'{--permit-uninstall,-U}'[Permit uninstallation of packages matching a package spec]:Spec: ' \
    '*'{--permit-downgrade,-d}'[Permit downgrades of packages matching a package spec]:Spec: ' \
    '*'{--permit-old-version,-o}'[Permit installs of versions worse than the best visible version in the slot for packages matching a package spec]:Spec: ' \
    '*'{--uninstalls-may-break,-u}'[Permit uninstalls that might break packages matching the specified package spec]:Spec: ' \
    '*'{--remove-if-dependent,-r}'[Remove dependent packages that might be broken by other changes if those packages match a package spec]:Spec: ' \
    '*'{--less-restrictive-remove-blockers,-l}'[Use less restrictive blockers for packages matching the supplied package spec]:Spec: ' \
    '(--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))' \
    '*'{--with,-w}'[Never keep installed packages with the supplied package name]:Spec: ' \
    '*'{--without,-W}'[Keep installed packages with the supplied package name if possible]:Spec: ' \
    '(--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]' \
    '(--no-follow-installed-dependencies --no-no-follow-installed-dependencies -n)'{--no-follow-installed-dependencies,--no-no-follow-installed-dependencies,-n}'[Ignore dependencies for installed packages]' \
    '*'{--no-dependencies-from,-0}'[Ignore dependencies (not blockers) from packages matching a package spec]:Spec: ' \
    '*'{--no-blockers-from,-!}'[Ignore blockers from packages matching a package spec]:Spec: ' \
    '(--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]' \
    '--suggestions[Control whether suggestions are taken]:When:((ignore display take))' \
    '--recommendations[Control whether recommendations are taken]:When:((ignore display take))' \
    '*'{--take,-t}'[Take suggestions matching a package spec]:Spec: ' \
    '*'{--take-from,-T}'[Take suggestions made by any package matching a package spec]:Spec: ' \
    '*'{--ignore,-i}'[Discard any suggestion matching a package spec]:Spec: ' \
    '*'{--ignore-from,-I}'[Discard all suggestions made by any package matching a package spec]:Spec: ' \
    '*'{--favour,-F}'[If there is a choice, favour the specified package name]:Spec: ' \
    '*'{--avoid,-A}'[If there is a choice, avoid the specified package name]:Spec: ' \
    '*'{--preset,-p}'[Preset a given constraint]:Spec: ' \
    '(--create-binaries -b)'{--create-binaries,-b}'[Create binary packages in the specified repository]:Repository:_cave_repositories' \
    '*'{--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 -C)'{--continue-on-failure,-C}'[Whether to continue after an error occurs]:When:((if-fetching never if-satisfied if-independent always))' \
    '*--skip-phase[Skip the named phases]:Phase:((fetch_extra killold init setup unpack prepare configure compile test test_expensive install strip preinst merge prerm postrm postinst tidyup))' \
    '*--abort-at-phase[Abort when a named phase is encountered]:Phase:((fetch_extra killold init setup unpack prepare configure compile test test_expensive install strip preinst merge prerm postrm postinst tidyup))' \
    '*--skip-until-phase[Skip every phase until a named phase is encountered]:Phase:((fetch_extra killold init setup unpack prepare configure compile test test_expensive install strip preinst merge prerm postrm postinst tidyup))' \
    '*--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_search]} )) ||
_cave_cmd_search()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '(--all-versions -a --no-all-versions)'{--all-versions,-a,--no-all-versions}'[Search in every version of packages]' \
    '(--type -t)'{--type,-t}'[Alter how patterns are matched]:Matching:((text exact))' \
    '(--and -& --no-and)'{--and,-\&,--no-and}'[If multiple patterns are specified, require that all patterns match]' \
    '(--not -! --no-not)'{--not,-\!,--no-not}'[Invert the results of pattern matches]' \
    '*'{--key,-k}'[Search the named metadata key]' \
    '(--name -n --no-name)'{--name,-n,--no-name}'[Search package names]' \
    '(--description -d --no-description)'{--description,-d,--no-description}'[Search package descriptions]'
}

(( ${+functions[_cave_cmd_show]} )) ||
_cave_cmd_show()
{
  _arguments -s : \
    '(--help -h)'{--help,-h}'[Display help messsage]' \
    '(--type -t)'{--type,-t}'[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]' \
    '(--raw-names -r)'{--raw-names,-r}'[Display raw key names]' \
    '*: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]' \
    '*:repository:_cave_repositories' && return 0
}

(( ${+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() {
  :
}

(( ${+functions[_cave_repositories]} )) ||
_cave_repositories() {
  local -a _cave_repositories
  _cave_repositories=( $(cave print-repositories) )
  _describe -t repository 'repository' _cave_repositories
}

_cave "${@}"