about summary refs log tree commit diff
path: root/Completion/Debian/_apt-get
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Debian/_apt-get')
-rw-r--r--Completion/Debian/_apt-get144
1 files changed, 111 insertions, 33 deletions
diff --git a/Completion/Debian/_apt-get b/Completion/Debian/_apt-get
index e54bd549b..981cb54c8 100644
--- a/Completion/Debian/_apt-get
+++ b/Completion/Debian/_apt-get
@@ -1,40 +1,118 @@
 #compdef apt-get
 
+local short_bool short_intlevel short_configfile short_arbitem
+local long_bool long_intlevel long_configfile long_arbitem
+local action
+
+short_bool=(h v d b s y f u m)
+short_intlevel=(q)
+short_configfile=(c)
+short_arbitem=(o)
+
+long_bool=(help version download-only compile build simulate just-print recon
+  no-act yes assume-yes fix-broken show-upgraded ignore-missing no-download
+  fix-missing ignore-hold no-upgrade force-yes print-uris)
+long_intlevel=(quiet silent)
+long_configfile=(config-file)
+long_arbitem=(option)
+
+action=(update upgrade install remove dist-upgrade dselect-upgrade clean
+  autoclean check source help)
+
+comp_action='compadd "$expl_action[@]" '"$action"
+
+regex_action=(
+ \(
+    /$'update\0' \|
+    /$'upgrade\0' \|
+    /$'install\0' /$'[^\0]#\0' !'_deb_packages uninstalled "$expl_packages[@]" || _deb_packages installed "$expl_packages[@]" ' \# \|
+    /$'remove\0' /$'[^\0]#\0' !'_deb_packages installed "$expl_packages[@]"' \# \|
+    /$'dist-upgrade\0' \|
+    /$'dselect-upgrade\0' \|
+    /$'clean\0' \|
+    /$'autoclean\0' \|
+    /$'check\0' \|
+    /$'source\0' /$'[^\0]#\0' !'_deb_packages avail "$expl_packages[@]"' \# \|
+    /$'help\0' \|
+    /"[]"	!"$comp_action"
+  \)
+)
+
+_apt_arguments _apt-get_sm "$regex_action[@]"
+
 _apt-get () {
-  # This doesn't handle command line of apt completely since command line
-  # parsing library for apt is too complex to handle by _arguments.
-  _arguments -s \
-    -{,-no-}d --{,no-}download-only \
-    -{,-no-}f --{,no-}fix-broken \
-    -{,-no-}h --{,no-}help \
-    -{,-no-}v --{,no-}version \
-    -{,-no-}m --{,no-}ignore-missing \
-    --{,no-}fix-missing \
-    --{,no-}no-download \
-    \*-{,-no-}q \*--{,no-}{quiet,silent} \
-    -{,-no-}s --{,no-}{simulate,just-print,dry-run,recon,no-act} \
-    -{,-no-}y --{,no-}{yes,assume-yes} \
-    -{,-no-}u --{,no-}show-upgraded \
-    -{,-no-}b --{,no-}{compile,build} \
-    --{,no-}ignore-hold \
-    --{,no-}no-upgrade \
-    --{,no-}force-yes \
-    --{,no-}print-uris \
-    {-{,-no-}c,--{,no-}config-file}':Configuration File:_files' \
-    {-o,--option}':Foo\:\:Bar=bar:' \
-    '*::command and packages:_apt-get_args'
-}
+  local tmp1 tmp2
+  local expl_action expl_opt expl_bool expl_configfile expl_packages
+  _description expl_action action
+  _description expl_opt option
+  _description expl_bool 'bool value'
+  _description expl_configfile 'config file'
+  _description expl_packages 'package'
+
+  typeset -A options short_to_option long_to_option
+
+  options=(
+    help		1
+    version		1
+    quiet		-1
+    download-only	1
+    compile		1
+    simulate		1
+    assume-yes		1
+    fix-broken		1
+    show-upgraded	1
+    no-download		1
+    fix-missing		1
+    ignore-hold		1
+    no-upgrade		1
+    force-yes		1
+    print-uris		1
+    config-file		1
+    option		-1
+  )
+
+  short_to_option=(
+    h help
+    v version
+    q quiet
+    d download-only
+    b compile
+    s simulate
+    y assume-yes
+    f fix-broken
+    u show-upgraded
+    m fix-missing
+    c config-file
+    o option
+  )
+
+  long_to_option=(
+    help		help
+    version		version
+    quiet		quiet
+    silent		quiet
+    download-only	download-only
+    compile		compile
+    build		compile
+    simulate		simulate
+    just-print		simulate
+    recon		simulate
+    no-act		simulate
+    yes			assume-yes
+    assume-yes		assume-yes
+    fix-broken		fix-broken
+    show-upgraded	show-upgraded
+    ignore-missing	fix-missing
+    no-download		no-download
+    ignore-hold		ignore-hold
+    no-upgrade		no-upgrade
+    force-yes		force-yes
+    print-uris		print-uris
+    config-file		config-file
+    option		option
+  )
 
-_apt-get_args () {
-  if (( CURRENT == 1 )); then
-    compadd "$@" - update upgrade dselect-upgrade dist-upgrade install remove source check clean autoclean help
-  else
-    case "$words[1]" in
-      install) _deb_packages uninstalled "$@" || _deb_packages installed "$@";;
-      remove) _deb_packages installed "$@";;
-      *) _deb_packages avail "$@";;
-    esac
-  fi
+  _apt-get_sm
 }
 
 _apt-get "$@"