# bash completion for woof               -*- shell-script -*-

_woof()
{
    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)
            _filedir cfg
            ;;
        -file|-iwad)
            _filedir '@(lmp|pk3|wad|zip)'
            ;;
        -playdemo|-timedemo|-fastdemo)
            _filedir '@(lmp|zip)'
            ;;
        -deh)
            _filedir '@(bex|deh)'
            ;;
    esac

    case $prev in
        -gameversion)
            COMPREPLY=(1.9 ultimate final hacx chex)
            ;;
        -complevel)
            COMPREPLY=(vanilla boom mbf mbf21)
            ;;
        -setmem)
            COMPREPLY=(dos622 dos71 dosbox)
            ;;
    esac

    if [[ $cur == -* ]]; then
        COMPREPLY=( $( compgen -W '-config -devparm -file -help -iwad -nomusic -nosfx -nosound -quiet -save -shotdir -verbose -version
-beta -coop_spawns -dog -dogs -episode -fast -loadgame -nm -nomo -nomonsters -pistolstart -respawn -skill -speed -turbo -uv -warp
-1 -2 -3 -fullscreen -noblit -nodraw -nograbmouse -nouncapped -uncapped -window
-altdeath -autojoin -avg -connect -deathmatch -dedicated -dm3 -dup -extratics -frags -left -nodes -oldsync -port -privateserver -right -server -servername -solo-net -timer
-bex -bexout -blockmap -bsp -deh -dehout -dumptranmap -force_old_zdoom_nodes -noautoload -nocheats -nodeh -noextras -nomapinfo -nooptions -tranmap
-fastdemo -levelstat -longtics -maxdemo -playdemo -record -recordfrom -recordfromto -shorttics -skipsec -strict -timedemo
-cl -complevel -gameversion -setmem -spechit -statdump
-nogui
' -- "$cur" ) )
    fi
} &&

complete -F _woof woof

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