blob: c27a8869f8f80ad614162bb5f4e2068bdd7e34b8 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#autoload
# Usage:
# _complete_opts H '' f '_files'
emulate -L zsh
setopt extendedglob
local done=yes
typeset -A option_pairs
option_pairs=("$@")
typeset -a no_arg with_arg opt_arg
no_arg=($option_pairs[(I)?])
opt_arg=($option_pairs[(I)?::]:s/:://)
with_arg=($option_pairs[(I)?:]:s/:// $opt_arg)
case "${#no_arg}-${#with_arg}" in
0-0)
if [[ x$PREFIX = x-* ]]; then
compadd -nQ - "$PREFIX$SUFFIX"
else
done=''
fi
;;
0-*)
if [[ x$PREFIX = x- ]]; then
IPREFIX="$IPREFIX$PREFIX"
PREFIX=
compadd $with_arg
elif [[ x$PREFIX = x-[${(j::)with_arg}] ]]; then
IPREFIX="$IPREFIX$PREFIX"
PREFIX=
eval $option_pairs[$IPREFIX[-1]:]
elif [[ x$PREFIX = x-[${(j::)with_arg}]* ]]; then
local p="$PREFIX[1,(r)[${(j::)with_arg}]]"
IPREFIX="$IPREFIX$p"
PREFIX="$PREFIX[$#p + 1,-1]"
eval $option_pairs[$IPREFIX[-1]:]
elif [[ x$words[$CURRENT-1] = x-[${(j::)with_arg}] ]]; then
local p="$words[$CURRENT - 1]"
eval $option_pairs[$p[-1]:]
else
done=''
fi
;;
*-0)
if [[ x$PREFIX = x-[${(j::)no_arg}]# ]]; then
IPREFIX="$IPREFIX$PREFIX"
PREFIX=
compadd $no_arg
else
done=''
fi
;;
*-*)
if [[ x$PREFIX = x-[${(j::)no_arg}]# ]]; then
IPREFIX="$IPREFIX$PREFIX"
PREFIX=
compadd $no_arg
compadd $with_arg
elif [[ x$PREFIX = x-[${(j::)no_arg}]#[${(j::)with_arg}] ]]; then
IPREFIX="$IPREFIX$PREFIX"
PREFIX=
eval $option_pairs[$IPREFIX[-1]:]
elif [[ x$PREFIX = x-[${(j::)no_arg}]#[${(j::)with_arg}]* ]]; then
local p="$PREFIX[1,(r)[${(j::)with_arg}]]"
IPREFIX="$IPREFIX$p"
PREFIX="$PREFIX[$#p + 1,-1]"
eval $option_pairs[$IPREFIX[-1]:]
elif [[ x$words[$CURRENT-1] = x-[${(j::)no_arg}]#[${(j::)with_arg}] ]]; then
local p="$words[$CURRENT - 1]"
eval $option_pairs[$p[-1]:]
else
done=''
fi
;;
esac
if [[ -z "$done" ]]; then
if (( $+complete_opts_verbose )); then
compadd - -${(k)^option_pairs:gs/://}
fi
false
else
true
fi
|