| 1 | # setop(1) completion -*- shell-script -*- |
| 2 | |
| 3 | _setop() |
| 4 | { |
| 5 | local current previous beforeprevious options combinationtypes outputtypes |
| 6 | _init_completion -s || return |
| 7 | |
| 8 | current="${COMP_WORDS[COMP_CWORD]}" |
| 9 | previous="${COMP_WORDS[COMP_CWORD-1]}" |
| 10 | beforeprevious="${COMP_WORDS[COMP_CWORD-2]}" |
| 11 | options="--help --version --quiet --combine --subtract --output --ignore-case --include-empty --input-separator --input-element --trim --output-separator" |
| 12 | combinationtypes="union intersection symmetric-difference formula" |
| 13 | outputtypes="set count is-empty contains equals has-subset has-superset" |
| 14 | |
| 15 | if [[ ${current} == -* ]] ; then |
| 16 | COMPREPLY=( $(compgen -W "${options}" -- ${current}) ) |
| 17 | return 0 |
| 18 | fi |
| 19 | |
| 20 | if [[ "${beforeprevious}" == --combine ]] && [[ "${previous}" == formula ]] ; then |
| 21 | COMPREPLY=() |
| 22 | return 0 |
| 23 | fi |
| 24 | |
| 25 | if [[ "${beforeprevious}" == --output ]] && [[ "${previous}" == contains ]] ; then |
| 26 | COMPREPLY=() |
| 27 | return 0 |
| 28 | fi |
| 29 | |
| 30 | case "${previous}" in |
| 31 | --combine) |
| 32 | COMPREPLY=( $(compgen -W "${combinationtypes}" -- ${current}) ) |
| 33 | ;; |
| 34 | --output) |
| 35 | COMPREPLY=( $(compgen -W "${outputtypes}" -- ${current}) ) |
| 36 | ;; |
| 37 | -n|--input-separator|-l|--input-element|-o|--output-separator|-t|--trim) |
| 38 | COMPREPLY=() |
| 39 | ;; |
| 40 | *) |
| 41 | _filedir |
| 42 | ;; |
| 43 | esac |
| 44 | } && |
| 45 | complete -F _setop setop |
| 46 | |
| 47 | # ex: filetype=sh |