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

# darcs command line completion.
# Copyright 2002 "David Roundy" <droundy@abridgegame.org>
#
have darcs &&
_darcs()
{
    local cur
    cur=${COMP_WORDS[COMP_CWORD]}

    COMPREPLY=()

    if (($COMP_CWORD == 1)); then
        COMPREPLY=( $( darcs --commands | grep "^$cur" ) )
        return 0
    fi

    COMPREPLY=( $( darcs ${COMP_WORDS[1]} --list-option | \
                   grep "^$cur" | sed 's/:/\\:/g') )
    return 0

}
[ "$have" ] && complete -F _darcs -o default darcs
