# shellcheck shell=dash

___x_cmd_yum_install(){
    if [ $# -eq 0 ]; then
        ___x_cmd_yum_install___app
    else
        ___x_cmd_yum___exec install "$@"
    fi
}

___x_cmd_yum_install___app(){
    local yumfp=;   yumfp="/var/cache/yum/updates.solv"
    [ -f "$yumfp" ] || {
        yum:info "Update the software in the repository."
        x yum upgrade -y || N="yum" M="yum update fail" log:ret:1
    }

    ___x_cmd_is_stdout2tty || {
        ___x_cmd_yum___lsraw
        return 0
    }

    yum:info "Use 'x yum -h' for help."
    yum:info "Select a package to install, or view information."

    local x_=""
    ___x_cmd_yum___lsraw_ || return
    local datafile="$x_"
    x_=; ___X_CMD_PICK_SHBIN_CODE="xrc yum" ___x_cmd storeread_ x pick --width 40 --col 10 --datafile "$datafile"
    local software="$x_"

    [ -n "$software" ] || {
        yum:info "Exit because no software is selected."
        return 0
    }

    local id
    x ui select id "What to do NEXT"    \
        "x yum install   $software"     \
        "x yum reinstall $software"     \
        "x yum info      $software"     \
        "browse repo of  $software"      \
        "yum --help"                    \
        "EXIT"     || return
    case "$id" in
        1)      x yum install   "$software" ;;
        2)      x yum reinstall "$software" ;;
        3)      x yum info      "$software" ;;
        4)      ___x_cmd_yum___repo_browse "$software" ;;
        5)      x help -m yum ;;
        6)      return 0 ;;
    esac
}
