From c9c202e3703e549242ff2bb828ae2113fb9f541c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 8 Mar 2009 12:47:34 +0100 Subject: Added arguments (-q etc) to zsh completion --- provides/zsh/completions/_pkg | 79 +++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 36 deletions(-) (limited to 'provides/zsh/completions') diff --git a/provides/zsh/completions/_pkg b/provides/zsh/completions/_pkg index 5e8ce9f..b28b1b3 100644 --- a/provides/zsh/completions/_pkg +++ b/provides/zsh/completions/_pkg @@ -28,45 +28,52 @@ function _pkg_notinstalled () { compadd $(diff <(pkg list) <(pkg list-all) | grep "^>" | cut -d " " -f 2) } -if (( CURRENT == 2 )) { - _pkg_action -} elif (( CURRENT == 3 )) { - case ${words[2]} in - changelog|check|delete|log|pull|push|refresh|remove|status|upgrade) - _pkg_installed - ;; - info) - _pkg_all - ;; - add|install) - _pkg_notinstalled - ;; - eval) - _message 'shell code for evaluation' - _wanted function expl 'internal function' \ - compadd $(grep -E '^\S*\s*\(\)\s*{' =pkg | cut -d ' ' -f 1) \ - $(grep -E 'function \S* (\(\) )?{' =pkg | cut -d ' ' -f 2) - ;; - *) - _message 'no more arguments' - ;; - esac -} elif [[ ${words[2]} = 'eval' ]] { - _message 'shell code for evaluation' - if (( CURRENT == 4 )) { - case ${words[3]} in - exec_hook|check_prereqs|*_collected|) +function _pkg_args { + if (( CURRENT == 2 )) { + case ${words[1]} in + changelog|check|delete|log|pull|push|refresh|remove|status|upgrade) _pkg_installed ;; - esac - } elif (( CURRENT == 5 )) { - case ${words[3]} in - exec_hook) - _wanted hook expl 'package hook' \ - compadd $(ls -1 ~/packages/${words[4]}/hooks 2> /dev/null) + info) + _pkg_all + ;; + add|install) + _pkg_notinstalled + ;; + eval) + _message 'shell code for evaluation' + _wanted function expl 'internal function' \ + compadd $(grep -E '^\S*\s*\(\)\s*{' =pkg | cut -d ' ' -f 1) \ + $(grep -E 'function \S* (\(\) )?{' =pkg | cut -d ' ' -f 2) + ;; + *) + _message 'no more arguments' ;; esac + } elif [[ ${words[1]} = 'eval' ]] { + _message 'shell code for evaluation' + if (( CURRENT == 3 )) { + case ${words[2]} in + exec_hook|check_prereqs|*_collected|) + _pkg_installed + ;; + esac + } elif (( CURRENT == 4 )) { + case ${words[2]} in + exec_hook) + _wanted hook expl 'package hook' \ + compadd $(ls -1 ~/packages/${words[3]}/hooks 2> /dev/null) + ;; + esac + } } -} else { - _message 'no more arguments' } + +_arguments \ + {-q,--quiet}'[quiet mode]' \ + {-d,--debug}'[debugmode]' \ + {-au,--auto-update}'[automatically update package list]' \ + '*'{-co,--checklinks-options}'[options for checklinks]:option' \ + {-p,--packagedir}'[package directory]:directory:_files -/' \ + ':action:_pkg_action' \ + '*::arguments:_pkg_args' -- cgit v1.2.3