# bash completion for Crispy Hexen              -*- shell-script -*-

_crispy_hexen()
{
    local cur prev words cword
    _init_completion || return

    # Save the previous switch on the command line in the prevsw variable
    local i prevsw=""
    for (( i=1; $cword > 1 && i <= $cword; i++ )); do
        if [[ ${words[i]} == -* ]]; then
            prevsw=${words[i]}
        fi
    done

    # Allow adding more than one file with the same extension to the same switch
    case $prevsw in
        -config|-extraconfig)
            _filedir cfg
            ;;
        -file|-iwad|-aa|-af|-as|-merge|-nwtmerge)
            _filedir wad
            ;;
        -playdemo|-timedemo)
            _filedir lmp
            ;;
    esac

    case $prev in
        -gameversion)
            COMPREPLY=(1.1 1.1r2)
            ;;
        -setmem)
            COMPREPLY=(dos622 dos71 dosbox)
            ;;
    esac

    if [[ $cur == -* ]]; then
        COMPREPLY=( $( compgen -W '-config -extraconfig -file -iwad -nomusic -nomusicpacks -nosfx -nosound -ravpic -response -savedir -version
-autohealth -fast -loadgame -moremana -nomonsters -respawn -skill -warp
-1 -2 -3 -display -fullscreen -geometry -height -noblit -nograbmouse -nomouse -width -window
-autojoin -class -connect -deathmatch -dup -extratics -nodes -oldsync -port -privateserver -randclass -server -servername -solo-net -timer
-aa -af -as -deh -merge -noautoload -nocheats -nwtmerge
-longtics -maxdemo -nodemoextend -noshortticfix -playdemo -record -recordfrom -strictdemos -timedemo
-gameversion -setmem -v10override
-artiskip -cdrom -dumpsubstconfig -mb -mmap -nogui -scripts
' -- "$cur" ) )
    fi
} &&

complete -F _crispy_hexen crispy-hexen

# ex: ts=4 sw=4 et filetype=sh
