summary refs log tree commit diff
path: root/Completion/Bsd/_bsd_pkg
blob: f60348479c0e8a3dfbbd1919e3b40bb51dc2062f (plain) (blame)
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
#compdef pkg_add pkg_delete pkg_info

(( $+functions[_bsd_pkg_packages] )) ||
_bsd_pkg_packages() {
  local ret=1 paths

  paths=( "${(@)${(@s.:.)PKG_PATH}:#}" )
  _files "$@" -g \*.tgz && ret=0
  (( $#path )) && _files "$@" -W paths -g \*.tgz && ret=0
  compadd "$@" - /usr/ports/packages/All/*.tgz && ret=0

  return ret
}

_bsd_pkg() {
  case "${words[1]:t}" in
  pkg_add)
    _arguments -s \
        '-v[be verbose]' \
	'-I[don'\''t execute installation scripts]' \
	'-n[don'\''t really install packages]' \
	'-R[don'\''t record]' \
	'-r[use remote fetching]' \
	'-f[force installation]' \
	'-M[run in master mode]' \
	'-S[run in slave mode]' \
        '-t:mktemp template:_files -/' \
        '-p:prefix directory:_files -/' \
        '*:package to install:_bsd_pkg_packages'
    ;;

  pkg_delete)
    _arguments -s \
        '-v[be verbose]' \
	'-D[don'\''t execute deinstallation scripts]' \
	'-n[don'\''t really deinstall packages]' \
	'-d[remove empty directories]' \
	'-f[force deinstallation]' \
        '-p:prefix directory:_files -/' \
        '*:package to deinstall:compadd - /var/db/pkg/*(\:t)'
    ;;

  pkg_info)
    _arguments -s \
        '(:)-a[show all installed packages]' \
	'-v[be verbose]' \
	'-p[show installation prefixes]' \
	'-q[be quiet]' \
	'-c[show comment fields]' \
	'-d[show long descriptions]' \
	'-D[show install-message files]' \
        '-f[show packing list instructions]' \
	'-i[show install scripts]' \
	'-I[show index lines]' \
	'-k[show deinstall scripts]' \
	'-r[show requirements scripts]' \
	'-R[show list list of installed requiring packages]' \
	'-m[show mtree files]' \
	'-L[show full pathnames of files]' \
        '-e[test if package is installed]:package name:compadd - /var/db/pkg/*(\:t)' \
        '-l:prefix directory:_files -/' \
        '-t:mktemp template:_files -/' \
        '(-a)*:package name:compadd - /var/db/pkg/*(\:t)'
    ;;
  esac
}

[[ -o kshautoload ]] || _bsd_pkg "$@"