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

# geant completion.
# if programmable auto completition of bash is enabled
# this will present the targets for geant if tab is pressed
#
# rename to geant and copy to /etc/bash_completition.d
#
# Copyright 2004 "Patrick Ruckstuhl" <rupatric@student.ethz.ch>
# $Date: 2004/12/08 18:38:16 $
# $Revision: 1.1 $
#
have geant &&
_geant()
{
    local cur prev options

    # is there a build.eant file?
    [[ -f build.eant ]] || return 0

    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}

    # get available targets
    options=`geant`
    # remove text around targets
    options=${options//geant/}
    options=${options//usage:/}

    COMPREPLY=( $( compgen -W "$options" | grep ^$cur ) )

    return 0

}
[ "$have" ] && complete -F _geant -o filenames geant