about summary refs log tree commit diff
path: root/Completion/Core/_all_labels
blob: f85478cb5e82de4b58ab2522a9c37f131f57e3e3 (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
#autoload

local gopt=-J len tmp pre suf ret=1 descr spec prev

if [[ "$1" = - ]]; then
  prev=-
  shift
fi

if [[ "$1" = -([12]|)[VJ] ]]; then
  gopt="$1"
  shift
fi

tmp=${argv[(ib:4:)-]}
len=$#
if [[ tmp -lt len ]]; then
  pre=$(( tmp-1 ))
  suf=$tmp
elif [[ tmp -eq $# ]]; then
  pre=-2
  suf=$(( len+1 ))
else
  pre=4
  suf=5
fi

while comptags "-A$prev" "$1" curtag spec; do
  _comp_tags="$_comp_tags $spec "
  if [[ "$curtag" = *:* ]]; then
    zformat -f descr "${curtag#*:}" "d:$3"
    _description "$gopt" "${curtag%:*}" "$2" "$descr"
    curtag="${curtag%:*}"

    "$4" "${(P@)2}" "${(@)argv[5,-1]}" && ret=0
  else
    _description "$gopt" "$curtag" "$2" "$3"

    "${(@)argv[4,pre]}" "${(P@)2}" "${(@)argv[suf,-1]}" && ret=0
  fi
done

return ret