#autoload # This can be used to add options or values with descriptions as matches. local cmd opt expl tmps tmpd tmpmd tmpms ret=1 showd _nm hide local type=value cmd="$words[1]" # Get the options. while getopts 'oc:' opt; do if [[ "$opt" = o ]]; then type=option else cmd="$OPTARG" fi done shift OPTIND-1 # Do the tests. `showd' is set if the descriptions should be shown. _tags -c "$cmd" "$type" || return 1 _style "$type" describe && showd=yes _description expl "$1" shift if [[ -n "$showd" ]]; then compdescribe -I ' -- ' "$@" else compdescribe -i "$@" fi [[ "$type" = option ]] && _style option hide && hide=yes while compdescribe -g args tmpd tmpmd tmps tmpms; do # See if we should remove the option prefix characters. if [[ -n "$hide" ]]; then if [[ "$PREFIX" = --* ]]; then tmpd=( "${(@)tmpd#--}" ) tmps=( "${(@)tmps#--}" ) elif [[ "$PREFIX" = [-+]* ]]; then tmpd=( "${(@)tmpd#[-+]}" ) tmps=( "${(@)tmps#[-+]}" ) fi fi compadd "$args[@]" "$expl[@]" -ld tmpd - "$tmpmd[@]" && ret=0 compadd "$args[@]" "$expl[@]" -d tmps - "$tmpms[@]" && ret=0 done return ret