# shellcheck shell=dash

___x_cmd_llmf_model_default(){
    local op="$1"
    case "$op" in
        set|get|get_)
                shift; ___x_cmd_llmf_model_default___"$op" "$@" ;;
        -h|--help)
                ___x_cmd help -m llmf model default; return ;;
        *)      ___x_cmd help -m llmf model default >&2; return 64 ;;
    esac
}

___x_cmd_llmf_model_default___set(){
    local model="$1"
    local x_
    [ -n "$model" ] || {
        ___x_cmd_runmode_allow_chatty || N=llmf M="Please provide model <name/version/quant.format>" log:ret:64

        x_=""; ___x_cmd_llmf_model_ls___app_ --all || return $?
        model="$x_"
        [ -n "$model" ] || return $?

        ___x_cmd ui yesno "Setting the default [model=$model] ?" || return $?
    }

    ___x_cmd_llmf_cfg set "model=${model}"
}

___x_cmd_llmf_model_default___get(){
    local x_=; ___x_cmd_llmf_model_default___get_ || return $?
    printf "%s\n" "$x_"
}

___x_cmd_llmf_model_default___get_(){
    ___x_cmd_llmf_cur x_:=model 2>/dev/null
    [ -n "$x_" ] || x_="$___X_CMD_LLMF_DEFAULT_FIRST_MODEL"
}
