# bash completion for mpf-cli                                   -*- shell-script -*-
# shellcheck shell=bash
#
# GENERATED by scripts/completions/gen.py from SabreTools/MPF at 6daa0e50.
# Do not edit: change the generator, then run `scripts/completions/gen.py write`.
#
# MPF.CLI takes a system, then options; or one standalone command.
# Systems and media types come from SabreTools.RedumpLib 3.6.1.
# Accepted although the help text does not list them:
#   commands: man lpm listpath
#   options:  (none)
# Also accepted, not offered: `?` (h and help are), the internal command names
# Help Manpage listpathmacros, a system by its full name, and the other
# spellings of program and media type names.

_mediapres_mpf_cli_drives()
{
    local d
    COMPREPLY=()
    for d in /dev/sr[0-9]*; do
        [[ -e $d && $d == "$cur"* ]] && COMPREPLY+=("$d")
    done
    ((${#COMPREPLY[@]})) || _filedir
}

_mediapres_mpf_cli()
{
    local cur prev words cword split
    _init_completion -s || return

    if ((cword == 1)); then
        local systems='pippin ajcd qis cd32 cdtv envizionsevosmartconsole fujitsufmtownsmarty
        ion hrush hvn hvnc hvnjr hvnxp l600 ixl hs vis xbox xbox360 xboxone
        xboxsx pce pc-fx gc superdisc wii wiiu 3do cdi polymega laseractive
        halcyon dc mcd ss ngcd psx ps2 ps3 ps4 ps5 psp wowow nuon iq vflash
        gamewave arch appleii mac atarist c64 acd fmt pc msx pc-88 pc-98 indigo
        x68k zxs ultra 3doarcade atari3do atronic auscomsystem1 ballygamemagic
        cps3 cubo fpp fpuri globalvrpc-basedsystems globalvrvortek
        globalvrvortekv3 icepc-basedhardware ite
        incredibletechnologiespc-basedsystems itouch kea kfb km2 konamipython
        kp2 ks573 ksgv kt konamipc-basedsystems meritindustriesboardwalk
        meritindustriesmegatouchforce mion meritindustriesmegatouchmaxx
        meritindustriesmegatouchxl npuri trf ns10 ns12 ns22 ns246 ns256 newjatre
        nichi nichibutsusupercd nichibutsux-ratesystem m2 pcarcade
        photoplaypc-basedsystems rawthrillspc-basedsystems alls chihiro
        chihiropc segaeuropa-r lindbergh lindpc naomi naomi2 naomipc nu nu11 nu2
        nusx sre sre2 srw segasystem32 stv cats szn quizard
        tsunamitsumomulti-gamemotionsystem ultracadepc-basedsystems newton piece
        audio-cd bd-video cybiko psxgs dvd-audio dvd-video enhanced-cd gp32
        hddvd-video hp48 ppc minidisc mp3 navi j2me palm photo-cd psion
        rainbowdisc sp21 zaurus seb sacd symbian iktv ti ksite uhdbd-video vcd
        whizkid'
        mapfile -t COMPREPLY < <(compgen -W "h help man version lc listcodes lo listconfig lpm listpath lm listmedia ls listsystems lp listprograms i interactive $systems" -- "$cur")
        return
    fi

    case ${words[1]} in
        \?|h|help|man|version|lc|listcodes|lo|listconfig|lpm|listpath|lm|listmedia|ls|listsystems|lp|listprograms|i|interactive)
            return
            ;;
    esac

    case $prev in
        -s|--speed|-r|--retries|-c|--custom)
            return
            ;;
        -u|--use)
            mapfile -t COMPREPLY < <(compgen -W 'aaru dic dreamdump redumper' -- "$cur")
            return
            ;;
        -t|--mediatype)
            mapfile -t COMPREPLY < <(compgen -W 'bdrom cdrom dvd fd gdrom hddvd hdd ldrom gc wii wiiu umd xgd' -- "$cur")
            return
            ;;
        -d|--device)
            _mediapres_mpf_cli_drives
            return
            ;;
        -m|--mounted)
            _filedir -d
            return
            ;;
        -f|--file)
            _filedir
            return
            ;;
    esac
    $split && return

    mapfile -t COMPREPLY < <(compgen -W '-u --use -t --mediatype -d --device -m --mounted -f --file -s --speed -r
        --retries -c --custom' -- "$cur")
} &&
    complete -F _mediapres_mpf_cli mpf-cli

# ex: filetype=sh
