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

_crispy_strife()
{
    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
            ;;
        -deh)
            _filedir seh
            ;;
    esac

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

    if [[ $cur == -* ]]; then
        COMPREPLY=( $( compgen -W '-config -devparm -extraconfig -file -iwad -nograph -nomusic -nomusicpacks -nosfx -nosound -novoice -response -savedir -version
-doubleammo -fast -loadgame -nomonsters -random -respawn -skill -turbo -warp
-1 -2 -3 -display -fullscreen -geometry -height -noblit -nodraw -nograbmouse -nomouse -width -window
-altdeath -autojoin -avg -connect -dedicated -dup -extratics -left -localsearch -nodes -oldsync -port -privateserver -query -right -search -server -servername -solo-net -timer
-aa -af -as -deh -merge -noautoload -nocheats -nwtmerge
-maxdemo -playdemo -record -solo-net -strictdemos -timedemo
-donut -gameversion -setmem -spechit
-cdrom -dumpsubstconfig -flip -mb -mmap -nogui -work
' -- "$cur" ) )
    fi
} &&

complete -F _crispy_strife crispy-strife

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