forked from freebsd/pkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_pkg.in
707 lines (694 loc) · 36.2 KB
/
_pkg.in
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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
#compdef pkg pkg-static
_pkg_cmd() {
%prefix%/sbin/pkg "${pkg_config[@]}" "$@"
}
_pkg_installed() {
local expl
_wanted packages expl package \
compadd "$@" - $(_call_program packages _pkg_cmd query "%n-%v")
}
_pkg_available_name() {
local expl scache
zstyle -t ":completion:${curcontext}:packages" remote-access || scache=1
_wanted packages expl package \
compadd "$@" - $(_call_program packages _pkg_cmd rquery ${scache:+--no-repo-update} "%n")
}
_pkg_aliases() {
local expl
_wanted aliases expl alias \
compadd "$@" - $(_call_program packages _pkg_cmd alias -ql)
}
_pkg_available() {
local ret=1 scache
_tags files packages
while _tags; do
if _requested files; then
_files "$@" -g "*.t?z" && ret=0
fi
if _requested packages; then
zstyle -t ":completion:${curcontext}:packages" remote-access || scache=1
compadd "$@" - $(_call_program packages _pkg_cmd rquery ${scache:+--no-repo-update} "%n-%v") && ret=0
fi
(( ret )) || break
done
return ret
}
_pkg_subcommands() {
local len full
local -a alts allmatching subcommands_f aliases_f subcommands_m aliases_m
subcommands_f=(
'add:compatibility interface to install a package'
'alias:list the command line aliases'
'annotate:add, modify or delete tag-value style annotations on packages'
'audit:report vulnerable packages'
'autoremove:remove orphaned packages'
'backup:back-up and restore the local package database'
'check:check for missing dependencies and database consistency'
'clean:clean old packages from the cache'
'config:display value of a configuration option'
'create:create software package distributions'
'delete:delete packages from the database and the system'
'fetch:fetch packages from a remote repository'
'help:display help information'
'info:display information about installed packages'
'install:install packages from remote package repositories'
'lock:lock package against modifications or deletion'
'query:query information about installed packages'
'plugins:list available plugins'
'register:register a package with the local database'
'repo:create a package repository catalogue'
'rquery:query information in repository catalogues'
'search:perform a search of package repository catalogues'
'set:modify information about packages in the local database'
'shell:open a debug shell'
'shlib:list packages that link against a specific shared library'
'stats:display package database statistics'
'unlock:unlock a package, allowing modification or deletion'
'update:update package repository catalogues'
'updating:display UPDATING information for a package'
'upgrade:perform upgrades of packaged software distributions'
'version:display versions of installed packages'
'which:display which package installed a specific file'
)
pkg_config=( -N ${(kv)opt_args[(I)-([cjoR]|config|jail|option|repo-conf-dir)]} )
aliases_f=(
"remove:synonym for 'delete'"
${${(f)"$(_call_program aliases _pkg_cmd alias -q)"}/ ##/:alias for }
)
zstyle -s ":completion:${curcontext}:" list-separator sep || sep=--
aliases_m=( ${aliases_f%%:*} )
subcommands_m=( ${subcommands_f%%:*} )
if zstyle -T ":completion:${curcontext}:" verbose; then
zstyle -T ":completion:${curcontext}:" verbose && disp=( -ld '${cmdtype}_d' )
_description '' expl '' # get applicable matchers
compadd "$expl[@]" -O allmatching -a aliases_m subcommands_m
len=${#${(O)allmatching//?/.}[1]} # length of longest match
for cmdtype in subcommands aliases; do
local -a ${cmdtype}_d
full=${cmdtype}_f
set -A ${cmdtype}_d \
${${(r.COLUMNS-4.)${(P)full}/(#s)(#m)[^:]##:/${(r.len.)MATCH[1,-2]} $sep }%% #}
alts+=( "${cmdtype}:pkg ${cmdtype%%(e|)s}:compadd ${(e)disp} -a ${cmdtype}_m" )
done
else
alts=(
'commands:pkg subcommand:compadd -a subcommands_m'
'aliases:pkg alias:compadd -a aliases_m'
)
fi
_alternative "$alts[@]"
}
_pkg_config_opts() {
_values 'configuration option' \
'ABI[ABI of package you want to install]:string' \
'ALIAS[define local aliases for various pkg(8) standard command lines]:key/value list' \
'ALLOW_BASE_SHLIBS[enable base libraries analysis]:boolean:(yes no)' \
'ALTABI[override the automatically detected old-form ABI]:string' \
'AUTOCLEAN[cleanout content of cache directory after upgrades or installations]:boolean:(yes no)' \
'AUTOMERGE[automatically merge configuration files]:boolean:(yes no)' \
'DEFAULT_ALWAYS_YES[default to "yes" for all questions requiring user confirmation]:boolean:(yes no)' \
'ASSUME_ALWAYS_YES[assume "yes" to all questions requiring user confirmation]:boolean:(yes no)' \
'CONSERVATIVE_UPGRADE[give priority to repo where a package was first installed from]:boolean:(yes no)' \
'CUDF_SOLVER[experimental\: use an external CUDF solver]:CUDF solver:_files' \
'CASE_SENSITIVE_MATCH[case-sensitive package matching]:boolean:(yes no)' \
'DEBUG_LEVEL[debugging level]:debug level:( {0..4} )' \
'DEBUG_SCRIPTS[activate debug mode (set -x) for scripts]:boolean:(yes no)' \
'DEVELOPER_MODE[make certain errors immediately fatal, adds warnings and suggestions]:boolean:(yes no)' \
'DOT_FILE[save SAT problem to the specified dot file]:file:_files' \
'EVENT_PIPE[send all event messages to specified FIFO or UNIX socket]:event pipe:_files' \
'FETCH_RETRY[number of times to retry a failed fetch of a file]:number of retries' \
'FETCH_TIMEOUT[time to wait for a file to download]:timeout (seconds)' \
'HANDLE_RC_SCRIPTS[automatically perform start/stop of service on install/removal]:boolean:(yes no)' \
'HTTP_USER_AGENT[define User-agent HTTP header to send]:user agent' \
'IGNORE_OSVERSION[ignore FreeBSD OS version check]:boolean:(yes no)' \
'INDEXDIR[directory to search for ports index file in]:directory:_files -/' \
'INDEXFILE[ports index file]:index file:_files' \
'IP_VERSION[restrict network access to specified IP version]:IP version:((0\:"system default" 4\:IPv4 6\:IPv6 ))' \
'LOCK_RETRIES[number of retries to obtain a lock]:retries' \
'LOCK_WAIT[wait time to regain a lock]:wait time (seconds):' \
'METALOG[if set, write a METALOG of the extracted files]:string' \
'NAMESERVER[hostname or IPv\[46\] address of a nameserver for DNS resolution]:name server:_hosts' \
'OSVERSION[FreeBSD OS version]:version' \
'PERMISSIVE[ignore conflicts while registering a package]:boolean:(yes no)' \
'PKG_CACHEDIR[specify cache directory for packages]:directory:_files -/' \
'PKG_CREATE_VERBOSE[make pkg_create(8) use verbose mode]:boolean:(yes no)' \
'PKG_DBDIR[specify directory to use for storing package database files]:directory:_files -/' \
'PKG_ENABLE_PLUGINS[activate plugin support]:boolean:(yes no)' \
'PKG_ENV[key/value pair of environment variables]:key/value list' \
'PKG_PLUGINS_DIR[specify directory for plugins]:directory:_files -/' \
'PKG_SSH_ARGS[extra arguments for ssh(1)]:ssh(1) arguments' \
'PLIST_KEYWORDS_DIR[directory containing definitions of plist keywords]:directory:_files -/' \
'PLIST_ACCEPT_DIRECTORIES[accept directories listed like plain files in plist]:boolean:(yes no)' \
'PLUGINS[list of plugins pkg(8) should load]:plugins' \
'PLUGINS_CONF_DIR[directory containing per-plugin configurations files]:directory:_files -/' \
'PORTSDIR[specify location of ports directory]:directory:_files -/' \
'READ_LOCK[use read locking for query database]:boolean:(yes no)' \
'REPOS_DIR[list of directories to search for repository configuration files]: : _sequence _directories' \
'REPOSITORIES[repository config in pkg.conf]:value' \
'REPO_AUTOUPDATE[automatically check for repo.sqlsite updates]:boolean:(yes no)' \
'RUN_SCRIPTS[run pre-/post-installation action scripts]:boolean:(yes no)' \
'SAT_SOLVER[experimental\: use an external SAT solver]:SAT solver:_files' \
'SQLITE_PROFILE[profile SQLite queries]:boolean:(yes no)' \
'SSH_RESTRICT_DIR[directory which ssh subsystem will be restricted to]:chroot:_files -/' \
'SYSLOG[log install/deinstall/upgrade operations to syslog(3)]:boolean:(yes no)' \
"UNSET_TIMESTAMP[don't include timestamps in package tar(1) archive]:boolean:(yes no)" \
'VALID_URL_SCHEME[valid URL schemes]:list' \
'VERSION_SOURCE[default database for comparing version numbers in pkg-version(8)]:database:(( I\:index P\:ports R\:remote ))' \
'VULNXML_SITE[specify URL to fetch vuln.xml vulnerability database from]: : _urls -F "( gopher:* file:* ftp:* )"' \
'WARN_SIZE_LIMIT[ask user when performing changes for more than this limit]:limit [1048576]' \
'WORKERS_COUNT[how many workers are used for pkg-repo]:workers:( {0..$(sysctl -n hw.ncpu)} )'
}
_pkg() {
_arguments -s -A '-*' \
'(-d --debug)'{-d,--debug}'[increment debug level]' \
'(-j --jail)'{-j+,--jail=}'[execute pkg(8) inside a jail(8)]:jail:_jails' \
'(-c --chroot)'{-c+,--chroot=}'[execute pkg(8) inside a chroot(8)]:chroot:_files -/' \
\*{-o+,--option=}'[set configuration option]:option:_pkg_config_opts' \
'(-C --config)'{-C,--config}'[use the specified configuration file]:configuration file:_files' \
'(- 1 *)'{-l,--list}'[list available commands and exit]' \
'(- 1 *)'{-v,--version}'[display pkg(8) version]' \
'-N[test if pkg(8) is activated and avoid auto-activation]' \
'(-R --repo-conf-dir)'{-R,--repo-conf-dir}'[specify directory for per-repository configuration files]: : _files' \
'-4[use IPv4 for fetching repository and packages]' \
'-6[use IPv6 for fetching repository and packages]' \
'1:sub command:_pkg_subcommands' \
'*::command:_pkg_args'
}
_pkg_args() {
local curcontext="$curcontext" state state_descr line expl ret=1
local -a pkg_config args
pkg_config=( -N ${(kv)opt_args[(I)-([cjoR]|config|jail|option|repo-conf-dir)]} )
state=()
service="$words[1]"
curcontext="${curcontext%:*}-$service:"
case "$words[1]" in
(add)
_arguments -C -A '-*' -s \
'(-A --automatic)'{-A,--automatic}'[mark the installed packages as automatic]' \
'(-f --force)'{-f,--force}'[force the reinstallation of package]' \
'(-I --no-scripts)'{-I,--no-scripts}'[ignore pre-/post-install scripts]' \
'(-M --accept-missing)'{-M,--accept-missing}'[ignore missing dependencies when installing]' \
'(-q --quiet)'{-q,--quiet}'[force quiet output]' \
'*:package:->packages' && ret=0
if [[ $state[1] == packages ]]; then
_alternative \
'packages:file:_files -f "*.t?z(-.)"' \
'urls: : _urls -F "( gopher:* file:* )"' && ret=0
fi
return ret
;;
(alias)
_arguments -A '-*' -s \
'(-l --list)'{-l,--list}'[list aliases]' \
'(-q --quiet)'{-q,--quiet}'[quiet]' \
'*:aliases:_pkg_aliases'
return
;;
(annotate)
_arguments -A '-*' -s \
'(-a --all 1 -g --glob -C --case-sensitive -i --case-insensitive -x --regex)'{-a,--all}'[annotate all installed packages]' \
'(-A --add -D --delete -M --modify -S --show)'{-A,--add}'[add a new annotation]' \
'(-C --case-sensitive -i --case-insensitive)'{-C,--case-sensitive}'[match package names case-sensitively]' \
'(-A --add -D --delete -M --modify -S --show 3)'{-D,--delete}'[delete an annotation]' \
'(-g --glob -a --all -x --regex)'{-g,--glob}'[treat package name as a shell glob pattern]' \
'(-C --case-sensitive -i --case-insensitive)'{-i,--case-insensitive}'[match package names case-sensitively]' \
'(-A --add -D --delete -M --modify -S --show)'{-M,--modify}'[modify an existing annotation]' \
'(-A --add -D --delete -M --modify -S --show 3)'{-S,--show}'[display an annotation]' \
'(-q --quiet)'{-q,--quiet}'[limit output to confirmatory questions]' \
'(-y --yes)'{-y,--yes}'[assume "yes" as the answer to all questions]' \
'(-g --glob -a --all -x --regex)'{-x,--regex}'[treat package name as an extended regular expression]' \
'1:package:_pkg_installed' \
'2:tag' \
'3:value'
return
;;
(audit)
_arguments -A '-*' -s \
'(-F --fetch)'{-F,--fetch}'[fetch database before checking]' \
'(-q --quiet)'{-q,--quiet}'[quiet]' \
'(-r --recursive)'{-r,--recursive}'[print packages that depend on vulnerable packages]' \
'(-f --file)'{-f+,--file=}'[local copy of the vulnerability database]:audit file:_files' \
'*:package:_pkg_installed'
return
;;
(autoremove)
_arguments -s \
'(-q --quiet)'{-q,--quiet}'[force quiet output]' \
'(-y --yes -n --dry-run)'{-y,--yes}'[assume yes when asked for confirmation]' \
'(-y --yes -n --dry-run)'{-n,--dry-run}'[assume no (dry run) when asked for confirmation]'
return
;;
(backup)
_arguments -s \
'(-q --quiet)'{-q,--quiet}'[force quiet output]' \
'(-d --dump -r --restore)'{-d+,--dump=}'[dump the local package database]:destination:_files' \
'(-d --dump -r --restore)'{-r+,--restore=}'[restore the local package database]:destination:_files'
return
;;
(check)
_arguments -A '-*' -s \
'(-B --shlibs)'{-B,--shlibs}'[reanalyze the shared libraries]' \
'(-d --dependencies)'{-d,--dependencies}'[check for and install missing dependencies]' \
'(-r --recompute)'{-r,--recompute}'[recompute sizes and checksums of installed packages]' \
'(-s --checksums)'{-s,--checksums}'[find invalid checksums]' \
'(-v --verbose)'{-v,--verbose}'[be verbose]' \
'(-n --dry-run)'{-n,--dry-run}"[check for missing dependencies but don't install them]" \
'(-y --yes)'{-y,--yes}'[assume yes for confirmations]' \
'(-q --quiet)'{-q,--quiet}'[force quiet output]' \
- '(all)' \
{-a,--all}'[process all packages]' \
- 'patterns' \
'(-a --all -i --case-insensitive -C --case-sensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'(-a --all -i --case-insensitive -C --case-sensitive)'{-C,--case-sensitive}'[case sensitive pattern matching]' \
'(-g --glob -x --regex)'{-x,--regex}'[process packages that match the regex pattern]' \
'(-g --glob -x --regex)'{-g,--glob}'[process packages that match the glob pattern]' \
'*:available package:_pkg_installed'
return
;;
(clean)
_arguments -s \
'(-a --all)'{-a,--all}'[delete all packages]' \
'(-n --dry-run)'{-n,--dry-run}'[show what packages would be removed]' \
'(-q --quiet)'{-q,--quiet}'[force quiet output]' \
'(-y --yes)'{-y,--yes}'[assume yes for confirmations]'
return
;;
(create)
_arguments -A '-*' -s \
'(-q --quiet)'{-q,--quiet}'[force quiet output]' \
'(-v --verbose)'{-v,--verbose}'[be verbose]' \
'(-n --no-clobber)'{-n,--no-clobber}"[don't overwrite existing packages]" \
'(-f --format)'{-f+,--format=}'[specify package output format]:format:(tar tgz tbz txz tzst)' \
'(-l --level)'{-l+,--level=}'[specify compression level]:level:(integer fast best)' \
'(-o --out-dir)'{-o+,--out-dir=}'[output directory]:outdir:_files -/' \
'(-r --root-dir)'{-r+,--root-dir=}'[specify root directory]:rootdir:_files -/' \
- '(manifest)' \
{-M+,--manifest=}'[specify manifest file]:manifest file:_files' \
- metadata \
'(-m --metadata)'{-m+,--metadata=}'[specify manifest directory]:manifestdir:_files -/' \
'(-p --plist)'{-p+,--plist=}'[specify package metadata using the legacy plist format]:plist' \
- '(all)' \
{-a,--all}'[process all packages]' \
- patterns \
'(-g --glob -x --regex)'{-g,--glob}'[process packages that match a glob pattern]' \
'(-g --glob -x --regex)'{-x,--regex}'[process packages that match a regex pattern]' \
'*:package:_pkg_installed'
return
;;
(delete|remove)
_arguments -A '-*' -s \
'(-q --quiet)'{-q,--quiet}'[force quiet output]' \
'(-n --dry-run -y --yes)'{-y,--yes}'[assume yes when asked for confirmation]' \
'(-y --yes -n --dry-run)'{-n,--dry-run}'[assume no (dry run) when asked for confirmation]' \
'(-f --force)'{-f,--force}'[force the package(s) to be removed]' \
'(-D --no-deinstall-script)'{-D,--no-deinstall-script}"[don't execute deinstallation scripts]" \
'(-R --recursive)'{-R,--recursive}'[delete all packages that require the list packages as well]' \
- '(all)' \
{-a,--all}'[process all packages]' \
- patterns \
'(-i --case-insensitive -C --case-sensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'(-i --case-insensitive -C --case-sensitive)'{-C,--case-sensitive}'[case sensitive pattern matching]' \
'(-g --glob -x --regex)'{-g,--glob}'[process packages that match a glob pattern]' \
'(-g --glob -x --regex)'{-x,--regex}'[process packages that match a regex pattern]' \
'*:package:_pkg_installed'
return
;;
(fetch)
_arguments -A '-*' -s \
'(-y --yes)'{-y,--yes}'[assume yes when asked for confirmation]' \
'(-r --repository)'{-r+,--repository=}'[specify the repository to fetch from]:repository:->repositories' \
'(-q --quiet)'{-q,--quiet}'[force quiet output]' \
'(-o --output)'{-o+,--output=}'[place files in a subdirectory named `All'\'' of the specified directory]: : _files -/' \
'(-d --dependencies)'{-d,--dependencies}'[fetch dependencies as well]' \
'(-U --no-repo-update)'{-U,--no-repo-update}'[suppress the automatic update of the repo catalogue]' \
- '(all)' \
'(-i --case-insensitive -C --case-sensitive)'{-a,--all}'[process all packages]' \
- patterns \
'(-i --case-insensitive -C --case-sensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'(-i --case-insensitive -C --case-sensitive)'{-C,--case-sensitive}'[case sensitive pattern matching]' \
'(-g --glob -x --regex)'{-g,--glob}'[process packages that match a glob pattern]' \
'(-g --glob -x --regex)'{-x,--regex}'[process packages that match a regex pattern]' \
'*:available package:_pkg_available' \
- '(updates)' \
{-u,--available-updates}'[fetch all available updates for currently installed packages]' && ret=0
;;
(help)
_wanted commands expl 'pkg subcommand' compadd - ${(f)"$(_call_program commands _pkg_cmd -l)"}
return
;;
(info)
local mutexopts='(-e --exists -d --dependencies -r --required-by -l --list-files -I --comment'
mutexopts+=' -R --raw -o --origin -O --by-origin -p --prefix -D --pkg-message -f --full)'
_arguments -A '-*' -s \
'(-A --annotations)'{-A,--annotations}'[display any annotations added to the package]' \
'(-q --quiet)'{-q,--quiet}'[force quiet output]' \
'--raw-format=[output format for raw output]:format:(json json-compact yaml)' \
'(-f --full)'{-f,--full}'[display full information]' \
${mutexopts}{-e,--exists}'[return 0 if specified package is installed]' \
${mutexopts}{-R,--raw}'[display the full manifest]' \
'(-d --dependencies)'{-d,--dependencies}'[display the dependencies]' \
'(-r --required-by)'{-r,--required-by}'[display the reverse dependencies]' \
'(-l --list-files)'{-l,--list-files}'[display all files]' \
'(-o --origin -O --by-origin)'{-o,--origin,-O,--by-origin}'[display origin]' \
'(-p --prefix)'{-p,--prefix}'[display prefix]' \
'(-D --pkg-message)'{-D,--pkg-message}'[display message]' \
'(-k --locked)'{-k,--locked}'[show the locking status]' \
'(-I --comment)'{-I,--comment}'[display comments]' \
'(-b --provided-shlibs)'{-b,--provided-shlibs}'[display shared libraries provided by the package]' \
'(-B --required-shlibs)'{-B,--required-shlibs}'[display all shared libraries used by the package]' \
'(-s --size)'{-s,--size}'[display the total size of the files installed by the package]' \
- '(all)' \
{-a,--all}'[process all packages]' \
- '(pkg-file)' \
{-F+,--file=}'[display information from an package archive]:package:_files' \
- patterns \
'(-i --case-insensitive -C --case-sensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'(-i --case-insensitive -C --case-sensitive)'{-C,--case-sensitive}'[case sensitive pattern matching]' \
'(-g --glob -x --regex)'{-g,--glob}'[process packages that match a glob pattern]' \
'(-g --glob -x --regex)'{-x,--regex}'[process packages that match a regex pattern]' \
'*:available package:_pkg_installed'
return
;;
(install)
_arguments -A '-*' -s \
'(-A --automatic)'{-A,--automatic}'[mark the installed packages as automatic]' \
'(-r --repository)'{-r+,--repository=}'[specify the repository to install packages from]:repository:->repositories' \
'(-U --no-repo-update)'{-U,--no-repo-update}'[suppress the automatic update of the repo catalogue]' \
'(-I --no-install-scripts)'{-I,--no-install-scripts}"[don't execute any pre/post-install scripts]" \
'(-M --ignore-missing)'{-M,--ignore-missing}'[ignore missing dependencies]' \
'(-n --dry-run -y --yes)'{-y,--yes}'[assume yes when asked for confirmation]' \
'(-y --yes -n --dry-run)'{-n,--dry-run}'[assume no (dry run) when asked for confirmation]' \
'(-f --force)'{-f,--force}'[force reinstallation if needed]' \
'(-F --fetch-only)'{-F,--fetch-only}"[don't perform actual installation of packages]" \
'(-q --quiet)'{-q,--quiet}'[quiet output]' \
'(-R --recursive)'{-R,--recursive}'[reinstall every package depending on matching expressions]' \
- '(all)' \
{-a,--all}'[process all packages]' \
- patterns \
'(-i --case-insensitive -C --case-sensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'(-i --case-insensitive -C --case-sensitive)'{-C,--case-sensitive}'[case sensitive pattern matching]' \
'(-g --glob -x --regex)'{-g,--glob}'[process packages that match a glob pattern]' \
'(-g --glob -x --regex)'{-x,--regex}'[process packages that match a regex pattern]' \
'*:available package:_pkg_available' && ret=0
;;
(lock)
args=( '--has-locked-packages[return 0 if at least one package is locked]' )
;&
(unlock)
_arguments -A '-*' -s $args \
'(-l --show-locked)'{-l,--show-locked}'[show a list of all locked packages]' \
'(-y --yes)'{-y,--yes}'[assume yes when asked for confirmation]' \
'(-y --yes -n --dry-run)'{-n,--dry-run}'[assume no (dry run) when asked for confirmation]' \
'(-q --quiet)'{-q,--quiet}'[quiet output]' \
- '(all)' \
{-a,--all}'[process all packages]' \
- patterns \
'(-i --case-insensitive -C --case-sensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'(-i --case-insensitive -C --case-sensitive)'{-C,--case-sensitive}'[case sensitive pattern matching]' \
'(-g --glob -x --regex)'{-g,--glob}'[process packages that match a glob pattern]' \
'(-g --glob -x --regex)'{-x,--regex}'[process packages that match a regex pattern]' \
'*:available package:_pkg_installed'
return
;;
(plugins)
_arguments -A '-*' '-l' '*:plugin'
return
;;
(query)
_arguments -C -s \
'(-)1:output format:->query' \
- '(all)' \
{-a,--all}'[process all packages]' \
- 'patterns' \
'(-i --case-insensitive -C --case-sensitive)'{-C,--case-sensitive}'[case sensitive pattern matching]' \
'(-i --case-insensitive -C --case-sensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'(-g --glob -x --regex)'{-g,--glob}'[process packages that match a glob pattern]' \
'(-g --glob -x --regex)'{-x,--regex}'[process packages that match a regex pattern]' \
'*:package:_pkg_installed' \
- '(eval)' \
{-e+,--evaluate=}'[process packages that match an evaluation]:evaluation:->evaluation' \
- '(files)' \
{-F,--file}'[process the specified package]:package:_files -g "*.t?z(-.)"' \
&& ret=0
;;
(register)
_arguments -A '-*' -s \
'(-A --automatic)'{-A,--automatic}'[mark the package to be automatically removed if no other packages depend on it]' \
'(-l --legacy)'{-l,--legacy}'[register as a legacy format]' \
'(-d --debug)'{-d,--debug}'[mark the package as an automatic dependency]' \
'(-t --test)'{-t,--test}'[enable testing mode]' \
- metadatadir \
'(-f --plist)'{-f+,--plist=}'[packing list file]:packing list file:_files' \
'(-m --metadata)'{-m+,--metadata=}'[metadata directory]:metadatadir:_files -/' \
'(-i --root)'{-i+,--root=}'[input path (aka root directory)]:input path:_files -/' \
- 'metadatafile' \
'!--relocate=:alternate root:_directories' \
'(-M --manifest)'{-M+,--manifest=}'[specify package manifest file]:manifest file:_files'
return
;;
(repo)
_arguments -A '-*' -s \
'(-l --list-files)'{-l,--list-files}'[generate list of all files in repo as filesite.txz archive]' \
'(-q --quiet)'{-q,--quiet}'[force quiet output]' \
'(-o --output-dir)'{-o+,--output-dir=}'[specify the location of the new repo]:repo location:_files -/' \
'(-m --meta-file)'{-m+,--meta-file=}'[use specified file as repository meta file instead of the defaults]:meta file:_files' \
':repository path:_files -/' \
':RSA key: _alternative "files\:RSA key\:_files" "commands\:commands\:_cmdstring"'
return
;;
(rquery)
_arguments -A '-*' -C -s \
'(-U --no-repo-update)'{-U,--no-repo-update}'[suppress the automatic update of the repo catalogue]' \
'(-r --repository)'{-r+,--repository=}'[specify the repository to search]:repository:->repositories' \
'(-I --index-line)'{-I,--index-line}'[print corresponding line from ports index file]' \
${words[(r)(-I|--index-line)]+!}':output format:->query' \
- '(all)' \
{-a,--all}'[process all packages]' \
- 'patterns' \
'(-i --case-insensitive -C --case-sensitive)'{-C,--case-sensitive}'[case sensitive pattern matching]' \
'(-i --case-insensitive -C --case-sensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'(-g --glob -x --regex)'{-g,--glob}'[process packages that match the glob pattern]' \
'(-g --glob -x --regex)'{-x,--regex}'[process packages that match a regex pattern]' \
'*:available package:_pkg_available_name' \
- '(eval)' \
{-e+,--evaluate=}'[process packages that match an evaluation]:evaluation:->evaluation' \
&& ret=0
;;
(search)
local -a label_opts modifier_opts
label_opts=(comment description name origin pkg-name)
modifier_opts=(
annotations arch categories comment depends-on description full
licenses maintainer name options pkg-size prefix repository
required-by shared-libs-{required,provided} size url version www
)
_arguments -A '-*' -s \
'(-x --regex -g --glob -e --exact)'{-g,--glob}'[process packages that match the glob pattern]' \
'(-x --regex -g --glob -e --exact)'{-x,--regex}'[process packages that match the regex pattern]' \
'(-x --regex -g --glob -e --exact)'{-e,--exact}'[process packages that match the string exactly]' \
'(-i --case-insensitive -C --case-sensitive)'{-C,--case-sensitive}'[case sensitive pattern matching]' \
'(-i --case-insensitive -C --case-sensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'(-U --no-repo-update)'{-U,--no-repo-update}'[suppress the automatic update of the repo catalogue]' \
'(-r --repository)'{-r+,--repository=}'[specify the repository to search]:repository:->repositories' \
'1:available package:_pkg_available_name' \
- set1 \
'(-L --label)'{-L+,--label=}'[select which identifying label is printed for each matched package]:field:( $label_opts )' \
'(-S --search)'{-S+,--search=}'[specify the field to search the repository catalogue on]:field:( $label_opts )' \
\*{-Q+,--query-modifier=}'[add an additional field to the result]:modifier:( $modifier_opts )' \
- set2 \
'(-D --description -c --comment)'{-c,--comment}'[use pattern matching on comments text]' \
'(-D --description -c --comment)'{-D,--description}'[use pattern matching on description text]' \
'(-d --depends-on)'{-d,--depends-on}'[list dependencies of the matched packages]' \
'(-f --full)'{-f,--full}"[show \`\`full'' information about the package]" \
'(-o --origins)'{-o,--origins}'[list packages by origins]' \
'(-p --prefix)'{-p,--prefix}'[display package installation prefix]' \
'(-q --quiet)'{-q,--quiet}'[be quiet]' \
'(-R --raw)'{-R,--raw}'[display full manifest]' \
'(-s --size)'{-s,--size}'[display the installed size]' \
'--raw-format=[output format for raw output]:format:(json json-compact yaml)' && ret=0
;;
(set)
local mutexopts='(-o --change-origin -A --automatic -n --change-name)'
_arguments -A '-*' -s \
${mutexopts}{-A+,--automatic=}'[mark as automatic or not]:flag:((1\:automatic 0\:not\ automatic))' \
'-v+[mark as vital or not]:flag:((1\:vital 0\:not\ vital))' \
${mutexopts}{-o+,--change-origin=}'[change the origin]:oldorigin\:neworigin' \
${mutexopts}{-n+,--change-name=}'[change the name]:oldname\:newname' \
'(-y --yes)'{-y,--yes}'[assume yes when asked for confirmation]' \
- '(all)' \
{-a,--all}'[process all packages]' \
- '(patterns)' \
'(-i --case-insensitive -C --case-sensitive)'{-C,--case-sensitive}'[case sensitive pattern matching]' \
'(-i --case-insensitive -C --case-sensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'(-g --glob -x --regex)'{-g,--glob}'[process packages that match the glob pattern]' \
'(-g --glob -x --regex)'{-x,--regex}'[process packages that match the regex pattern]' \
'*:package:_pkg_installed'
return
;;
(shell)
_arguments -s \
':database:_files'
return
;;
(shlib)
_arguments -A '-*' -s \
'(-q --quiet)'{-q,--quiet}'[force quiet output]' \
'(-P --provides)'{-P,--provides}'[show the package which provides the library]' \
'(-R --requires)'{-R,--requires}'[show installed packages which requires the library]' \
':library:'
return
;;
(stats)
_arguments -A '-*' -s \
'(-q --quiet)'{-q,--quiet}'[be quiet]' \
- '(remote)' \
{-r,--remote}'[display stats only for the remote package database]' \
- '(local)' \
{-l,--local}'[display stats only for the local package database(s)]' \
- '(size)' \
{-b,--bytes}'[display space usage, in bytes]'
return
;;
(update)
_arguments -A '-*' -s \
'(-f --force)'{-f,--force}'[force update]' \
'(-q --quiet)'{-q,--quiet}'[be quiet]' \
'(-r --repository)'{-r+,--repository=}'[specify the repository to update from]:repository:->repositories' && ret=0
;;
(updating)
# recall dates starting the from the beginning of this month.
# zstyle ':completion:*:*:pkg-updating:option-(d|-date)-1:*' fake ${(%):-"%D{%Y%m}"}{01..${(%):-"%D{%d}"}}
_arguments -A '-*' -s \
'(-d --date)'{-d+,--date=}'[only entries newer than date are shown]:date' \
'(-f --file)'{-f+,--file=}'[specify alternative location of the UPDATING file]:UPDATING file:_files' \
'(-i --case-insensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'*:package:_pkg_installed'
return
;;
(upgrade)
_arguments -A '-*' -s \
"(-F --fetch-only)"{-F,--fetch-only}"[don't install packages, merely fetch them]" \
'(-y --yes -n --dry-run)'{-n,--dry-run}'[assume no (dry run) when asked for confirmation]' \
'(-n --dry-run -y --yes)'{-y,--yes}'[assume yes when asked for confirmation]' \
'(-f --force)'{-f,--force}'[upgrade/reinstall everything]' \
'(-i --case-insensitive -C --case-sensitive)'{-C,--case-sensitive}'[case sensitive pattern matching]' \
'(-i --case-insensitive -C --case-sensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'(-U --no-repo-update)'{-U,--no-repo-update}'[suppress the automatic update of the repo catalogue]' \
'(-I --no-install-scripts)'{-I,--no-install-scripts}"[don't execute any pre/post-install scripts]" \
'(-q --quiet)'{-q,--quiet}'[be quiet]' \
'(-r --repository)'{-r+,--repository=}'[specify the repository to upgrade from]:repository:->repositories' \
'(-g --glob -x --regex)'{-g,--glob}'[process packages that match a glob pattern]' \
'(-g --glob -x --regex)'{-x,--regex}'[process packages that match a regex pattern]' \
'*:available package:_pkg_installed' && ret=0
;;
(version)
_arguments -A '-*' -s \
- '(testversion)' \
{-t+,--test-version=}'[test a pair of version number strings]: : _message -e values "version string": : _message -e values "version string"' \
- '(testpattern)' \
{-T+,--test-pattern=}'[compare pkgname against a shell glob pattern]:package:_pkg_installed: : _message -e values glob' \
- other \
'(-r --repository -P --ports -R --remote -I --index)'{-I,--index}'[use INDEX file]' \
'(-r --repository -P --ports -R --remote -I --index)'{-P,--ports}'[force checking against the ports tree]' \
'(-P --ports -R --remote -I --index)'{-R,--remote}'[use remote repository]' \
'(-o --origin)'{-o,--origin}'[display package origin, instead of package name]' \
'(-q --quiet)'{-q,--quiet}'[be quiet]' \
'(-v --verbose)'{-v,--verbose}'[be verbose]' \
${words[(r)(-*[PI]*|--(index|ports))]+!}'(-r --repository)'{-r+,--repository=}'[specify the repository to ]:repository:->repositories' \
'(-U --no-repo-update)'{-U,--no-repo-update}'[suppress the automatic update of the repo catalogue]' \
'(-L --not-like -l --like)'{-l+,--like=}'[display only the packages with a given status flag]:flag:((\< = \>))' \
'(-l --like -L --not-like)'{-L+,--not-like=}'[display only the packages without a given status flag]:flag:((\< = \>))' \
'(-O --match-origin)'{-M+,--match-origin=}'[display only packages matching specified origin]:origin' \
'(-n --match-name)'{-M+,--match-name=}'[display only packages matching specified name]:name' \
'(-i --case-insensitive -C --case-sensitive)'{-C,--case-sensitive}'[case sensitive pattern matching]' \
'(-i --case-insensitive -C --case-sensitive)'{-i,--case-insensitive}'[case insensitive pattern matching]' \
'(-x --regex -g --glob -e --exact)'{-g+,--glob=}'[display packages that match the glob pattern]:glob pattern' \
'(-x --regex -g --glob -e --exact)'{-x+,--regex=}'[display packages that match the regex pattern]:regex pattern' \
'(-x --regex -g --glob -e --exact)'{-e+,--exact=}'[display the packages that exactly match the string]:string' && ret=0
;;
(which)
_arguments -A '-*' -s \
'(-q --quiet)'{-q,--quiet}'[be quiet]' \
'(-o --origin)'{-o,--origin}'[display origin]' \
':file:_files' \
- '(glob)' \
{-g,--glob}'[treat filename as a glob pattern]' \
{-m,--show-match}'[show files that match the glob pattern (requires -g)]' \
- '(PATH)' \
{-p,--path-search}'[search for the filename in PATH]'
return
;;
(*)
# expand aliases, avoid recursing multiple times if aliases are recursive
if [[ $funcstack[2] != _pkg_args ]] && line="$(_call_program pkg-alias _pkg_cmd alias "$words[1]")"; then
(( CURRENT -= $#words ))
words[1]=( ${=${line#*\'}%\'} )
(( CURRENT += $#words ))
_pkg_args
else
# fallback to default completion for an unknown command
_default
fi
return
;;
esac
[[ -z $state ]] && return ret
if [[ $state = repositories ]]; then
local -U repos
repos=( $(_call_program repositories _pkg_cmd query '%R') )
_wanted -x repositories expl repository compadd -a repos
return
fi
local -a specs elements
elements=(
'd:dependencies' 'r:reverse dependencies' 'C:categories'
'O:options' 'L:licenses' 'A:annotations'
'B:required share libraries' 'b:provided shared libraries'
)
specs=(
'n:package name' 'o:origin' 'p:prefix' 'm:maintainer'
'c:comment' 'e:description' 'w:home page' 's:size'
'Q:alternative architecture' 'q:architecture' 'M:message'
'?:if info exists' '#:no of elements'
)
if [[ $service = query ]]; then
specs+=( 'a:automatic' 'k:locked' 't:timestamp' 'V:vital' )
elements+=( 'F:files' 'D:directories' 'U:users' 'G:groups' )
fi
if [[ $state = query ]]; then
specs+=( 'v:version' 'l:license' 'R:repository' )
compset -P '(%[^sOFdrA?#]|%?[^%]|[^%])#'
else
compset -P '(%[^OFdrA?#]|%?[^%]|[^%])#'
fi
if compset -P '%s'; then
_describe -t units unit '( b:bytes h:human\ readable )' -S '' && ret=0
elif compset -P '%F'; then
_describe -t properties property '( p:path s:sum )' -S '' && ret=0
elif compset -P '%O'; then
_describe -t properties property '( k:key v:value d:default D:description )' -S '' && ret=0
elif compset -P '%[dr]'; then
_describe -t properties 'dependency property' '( n:name o:origin v:version )' -S '' && ret=0
elif compset -P '%A'; then
_describe -t properties property '( t:tag s:value )' -S '' && ret=0
elif compset -P '%(|\\)[?#]'; then
_describe -t lists list elements -S '' && ret=0
else
[[ $IPREFIX = *%(#b)([${(j..)elements%%:*}])* ]] &&
elements=( ${(M)elements:#$match[1]:*} )
if [[ $state = evaluation ]]; then
_tags variables operators
else
_tags patterns elements
fi
while _tags; do
_requested elements && _describe -t elements 'list element' elements -p % -S '' && ret=0
_requested variables && _describe -t variables 'variable' specs -p % -S '' && ret=0
_requested patterns && _describe -t patterns 'query specifier' specs -p % -S '' && ret=0
_requested operators expl operator compadd -S '' \~ {,\!,\>,\<}= \> \< \&\& \|\| && ret=0
(( ret )) || break
done
fi
return ret
}
_pkg "$@"