about summary refs log tree commit diff
path: root/Completion/Debian/Command/_wajig
blob: 350eee65885a6604e25a58ba643fd15cb4a20df0 (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
69
70
71
72
73
74
75
76
77
#compdef wajig

local curcontext="$curcontext" state line cmds argno ret=1

_arguments -C -s \
  '(- 1 *)'{-h,--help}'[print usage message]' \
  '(- 1 *)--version[display version information]' \
  '(-q --quiet)'{-q,--quiet}'[do everything quietly]' \
  '(-s --simulate)'{-s,--simulate}"[trace but don't execute]" \
  '(-t --teaching)'{-t,--teaching}'[trace the sequence of commands performed]' \
  '(-v --verbose)'{-v,--verbose}'[increase (or set) the level of verbosity]' \
  '1: :->cmds' \
  '*: :->args' && ret=0

case $state in
  cmds)
    cmds=( ${${(M)${(f)"$(wajig commands 2>/dev/null)"}:# [^-]*}/(#b) ([^ ]#) #(*)/$match[1]:$match[2]:l} )

    _describe -t commands 'wajig command' cmds && ret=0
  ;;
  args)
    (( argno = $#line-1 ))
    case ${line[1]:gs/-/} in
      autoalts|autoalternatives|updatealts)
	((argno==1)) && _wanted alternatives expl alternative \
	    _files -W /var/lib/dpkg/alternatives && ret=0
      ;;
      listfiles|repackage|package)
	((argno==1)) || break
      ;&
      hold|large|readme|reconfigure|reinstall|remove|removedepend|showremove|size?|upgrade)
	_wanted package expl 'package' _deb_packages installed && ret=0
      ;;
      purgedepend)
	((argno==1)) && _wanted package expl 'package' _deb_packages xinstalled && ret=0
      ;;
      purge)
	_wanted package expl 'package' _deb_packages xinstalled && ret=0
      ;;
      autoinstall|force|showinstall|installr|recommended|installrs|installs|suggested|install/*)
	_wanted package expl 'package' _deb_packages uninstalled && ret=0
      ;;
      install)
	_alternative \
	  'packages:package:_deb_packages uninstalled' \
	  'files:package file:_files -g "*.deb(-.)"' && ret=0
      ;;
      bug|bugs|dependents|geturl)
	((argno==1)) || break
      ;&
      available|build|builddepend|changelog|describe|whatis|detail|details|show|news|policy|download|source|status|recdownload)
	_wanted package expl 'package' _deb_packages available && ret=0
      ;;
      unhold)
	_wanted package expl 'package' _deb_packages held && ret=0
      ;;
      filedownload|downloadfile|fileinstall|installfile|fileremove|removefile|indfile)
	((argno==1)) && _files && ret=0
      ;;
      whichpkg)
	_files
      ;;
      rpminstall|rpmtodeb|rpm2deb)
	((argno==1)) && _files -g '*.rpm(-.)' && ret=0
      ;;
      searchapt)
	_wanted distributions expl distribution \
	    compadd stable testing unstable && ret=0
      ;;
      reload|restart|start|stop)
	((argno==1)) && _services && ret=0
      ;;
    esac
  ;;
esac

return ret