| 1 | # bash completion for is_installed |
| 2 | # -*- shell-script -*- |
| 3 | |
| 4 | _is_installed() |
| 5 | { |
| 6 | local cur prev words cword |
| 7 | _init_completion -n = || return |
| 8 | |
| 9 | local split=false |
| 10 | |
| 11 | local i action |
| 12 | for (( i=1; i<${#words[@]}; i++ )); do |
| 13 | if [[ "${words[i]}" != -* ]]; then |
| 14 | action="${words[i]}" |
| 15 | break |
| 16 | fi |
| 17 | done |
| 18 | |
| 19 | case "$action" in |
| 20 | help) |
| 21 | # no argument required |
| 22 | return |
| 23 | ;; |
| 24 | info) |
| 25 | COMPREPLY=( $(cd /var/log/packages; compgen -f -- "$cur") ) |
| 26 | return |
| 27 | ;; |
| 28 | file-search) |
| 29 | # argument required but no way to help |
| 30 | return |
| 31 | ;; |
| 32 | *) |
| 33 | COMPREPLY+=( $(compgen -W 'help info file-search' -- "$cur") ) |
| 34 | return |
| 35 | ;; |
| 36 | esac |
| 37 | |
| 38 | } |
| 39 | |
| 40 | complete -F _is_installed is_installed |
| 41 | |
| 42 | # ex: filetype=sh |