# shellcheck shell=dash

___x_cmd log init whisper

xrc:mod:lib     whisper     dictate/_index model/_index __convert advise prepare merge

___x_cmd_whisper___main(){
    [ "$#" -gt 0  ] ||  set -- nv
    local op="$1"; shift
    case "$op" in
        -h|--help)      ___x_cmd help -m whisper "$@" ;;

        nv)             ___x_cmd_whisper___nv               "$@" ;;

        model)          ___x_cmd_whisper_model              "$@" ;;
        exec)           ___x_cmd_whisper___exec             "$@" ;;
        --|d|dictate)   ___x_cmd_whisper___dictate          "$@" ;;
        download)       ___x_cmd_whisper_model download     "$@" ;;

        merge)          ___x_cmd_whisper_merge              "$@" ;;

        *)              ___x_cmd_whisper___dictate "$op"    "$@" ;;
    esac
}

___x_cmd_whisper___exec(){
    ___x_cmd whispercpp "$@"
}

# x whisper --srt -o output.srt input.mp4
# x whisper merge output.srt input.mp4 output.mp4

___x_cmd_whisper___nv(){
    local id
    local cmd

    ___x_cmd ui select id,cmd  "What's next for whisper"           \
        "x whisper --help"                                  \
        "x whisper model        # Whisper model management" \
        "x open https://x-cmd.com/mod/whisper"              \
        "x open https://x-cmd.com/pkg/whispercpp"           \
        "ABORT"

    case "$id" in
        5)      return 0 ;;
        *)      eval "$cmd" ;;
    esac
}
