# shellcheck shell=dash

___x_cmd_winget___ensure(){
    ___x_cmd pwsh <"$___X_CMD_ROOT_MOD/winget/lib/install.ps1"
}


___x_cmd_winget_install(){
    if [ "$#" -eq 0 ]; then
        if ___x_cmd_is_stdout2tty && ___x_cmd_runmode_allow_chatty; then
            ___x_cmd_winget_ls___all
            return
        else
            ___x_cmd help -m winget install >&2
            return 64
        fi
    fi

    ___x_cmd_winget___proxy run ___x_cmd_winget___bin "install" "$@"
    local err="$?"
    case "$err" in
        0)  ___x_cmd notify "✅ Successfully winget install $*." ;;
        *)  ___x_cmd notify "🔍 Failed to winget install $*. [exitcode=$err]." ;;
    esac
    return $err
}
