#-*- mode: shell-script;-*-

# darcs command line completion for zsh -- example
# Copyright 2002 "David Roundy" <droundy@abridgegame.org>
#

# Old zsh compctl style
_darcs_first()
{
    local prefix
    prefix=$1
    reply=( $( darcs --commands | grep "^${prefix}" ) )
}

_darcs_rest()
{
    local first second prefix rest
    prefix=$1
    read -c first second rest
    reply=( $( darcs ${second} --list-option | grep "^${prefix}") )
}
# this would complete on files as well, if first and rest didn't match.
# since darcs does this when passed --list-option, no need
# compctl -F -x 'p[1,1]' -K _darcs_first - 'p[2,-1]' -K _darcs_rest -- darcs
compctl -x 'p[1,1]' -K _darcs_first - 'p[2,-1]' -K _darcs_rest -- darcs

