# shellcheck shell=dash

___x_cmd_hok_la(){
    if ___x_cmd_is_stdout2tty && ___x_cmd_runmode_allow_chatty ; then
        ___x_cmd_hok_la___fz
    else
        ___x_cmd_scoop_la___raw
    fi
}

___x_cmd_hok_la___fz(){
    local x_=;
    ___x_cmd_scoop___fzf_ ___x_cmd_scoop_la___raw || return
    [ -n "$x_" ] || return

    local software="${x_%% *}"
    local bucket="${x_##* }"
    local _id; local _cmd
    ___x_cmd ui select _id,_cmd NEXT    \
        "x hok info     ${bucket}/^$software$"  \
        "x hok install  ${bucket}/${software}"    \
        "return"     || return

    case "$_id" in
        1)  hok:info "cmd -> $_cmd"; ___x_cmd hok info "${bucket}/^${software}$" ;;
        2)  hok:info "cmd -> $_cmd"; ___x_cmd hok install "${bucket}/${software}" ;;
        *)  return ;;
    esac
}

___x_cmd_hok___fzfinfo(){
    local software="${1%/*}"
    local bucket="${1##*/}"
    ___x_cmd_scoop___fzfinfo "$software" "$bucket"
}

