about summary refs log tree commit diff
path: root/Completion/Unix/Command/_mercurial
blob: 06212314e499b3d9a944b5fc2781802f25c8422a (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
#compdef hg

local context state line
typeset -A opt_args

if (( ! $+_mercurial_cmds )); then
  local _mercurial_cmds
  _mercurial_cmds=( $($service debugcomplete) )
fi
if (( ! $+_mercurial_options )); then
  local _mercurial_options
  _mercurial_options=( $($service debugcomplete --options) )
fi

_arguments \
  "$_mercurial_options[@]" \
  '*:command:->subcmds' && return 0

case "$state" in
  (subcmds)
    if (( CURRENT == 2 )); then
      compadd -- "$_mercurial_cmds[@]"
    else
      _files
    fi
  ;;
esac