blob: db2011727caab2f22268c459a6693576c3807553 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#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 args
local type=values
cmd="$words[1]"
# Get the options.
while getopts 'oc:' opt; do
if [[ "$opt" = o ]]; then
type=options
else
cmd="$OPTARG"
fi
done
shift OPTIND-1
# Do the tests. `showd' is set if the descriptions should be shown.
_tags -c "$cmd" any "$type" || return 1
_style "$type" description yes && showd=yes
_description expl "$1"
shift
if [[ -n "$showd" ]]; then
compdescribe -I ' -- ' "$@"
else
compdescribe -i "$@"
fi
[[ "$type" = options ]] && _style options prefix-hidden yes && 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
|