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

_crispy_heretic()
{
    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 hhe
            ;;
    esac

    case $prev in
        -hhever)
            COMPREPLY=(1.0 1.2 1.3)
            ;;
        -setmem)
            COMPREPLY=(dos622 dos71 dosbox)
            ;;
    esac

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

complete -F _crispy_heretic crispy-heretic

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