# shellcheck shell=dash

___X_CMD_BUN_LOADED=
___x_cmd_bun_loaded(){
    [ -n "$___X_CMD_BUN_LOADED" ]
}

___x_cmd_bun_load(){
    ! ___x_cmd_bun_loaded || return 0

    ___x_cmd_bun_load_checkenv || {
        bun:debug "Cannot find bun installed in this current environment"
        ___x_cmd snap --run bun --version >/dev/null
        return
    }

    # TODO: In the future, we need to check the current version is good enough.

    ___X_CMD_BUN_LOADED=1
}

# TODO: Add yes and quiet in the future
___x_cmd_bun_load_checkenv(){
    ___x_cmd hascmd bun   || return
}
