

# x yay --install
# x yay --install --source

___x_cmd_yay___install(){
    local mode=bin
    case "$1" in
        -h|--help)  ___x_cmd help -m yay --install "$@"; return 0 ;;
        --bin)      mode=bin ;;
        --source)   mode=source ;;
    esac

    yay:info --cmd "pacman -Sy --needed git base-devel" "Install dependencies"
    ___x_cmd_hascmd pacman || N=yay M="pacman command not found"     log:ret:1

    ___x_cmd sudo pacman -Sy --needed git base-devel || return $?

    local folder="$___X_CMD_ROOT_TMP/yay/yay-bin"
    local giturl="https://aur.archlinux.org/yay-bin.git"

    if [ "$mode" = source ]; then
        folder="$___X_CMD_ROOT_TMP/yay/yay-source"
        giturl="https://aur.archlinux.org/yay.git"
    fi

    ___x_cmd ensurefp "$folder"

    # clone to the folder ... then install ...
    # using yay-bin to avoid download golang

    ___x_cmd git clone "$giturl" "$folder"

    (
        ___x_cmd_cd0 "$folder"
        makepkg -si
    )
}

