feat: menu CLI minimalista (pure-bash, cero dependencias)

- core/menu.sh: show_menu() con navegacion ANSI pura (read -sn1 + clear via printf ANSI), flechas up/down + Enter, atajo numerico 1-5/0, q/ESC salir, guard EOF
- main.sh: menu como entrada por defecto (los flags --yes/--no-gpu la bypassan); despacho sin logica de negocio (MODE: full/neo/openvino + subcomandos doctor/uninstall)
- Control de flujo: MODE!=openvino salta NEO; MODE=neo finaliza tras NEO (sin abrir OpenVINO)
- Verificado: tecla 4 -> doctor completo, q/ESC/EOF -> salida limpia, opcion 2 sin root -> error de privilegios
This commit is contained in:
stornic56
2026-09-29 12:05:17 -05:00
parent 09de89f31e
commit 5c82b320fd
2 changed files with 95 additions and 1 deletions
+62
View File
@@ -0,0 +1,62 @@
#!/bin/bash
# ------------------------------------------------------------------------------
# Menu minimalista pure-bash (cero dependencias externas: ANSI + read -sn1).
# Navegacion: flechas up/down + Enter, teclas numericas como atajo, q/ESC salir.
# Devuelve: 0=salir, 1=instalacion completa, 2=solo NEO, 3=solo OpenVINO,
# 4=doctor, 5=desinstalar
# Requiere: common.sh ya sourceado (print_*), no necesita root para navegar.
# ------------------------------------------------------------------------------
MENU_OPTS=("Instalacion completa" "Solo drivers NEO" "Solo OpenVINO Runtime" "Verificar instalacion (doctor)" "Desinstalar" "Salir")
show_menu() {
local sel=0
local n=${#MENU_OPTS[@]}
local key rest i opt pad
while true; do
printf '\033[2J\033[H'
echo ""
echo "┌──────────────────────────────────────────────┐"
echo "│ OpenVINO Simple Installer 2026.4 │"
echo "└──────────────────────────────────────────────┘"
echo ""
i=0
for opt in "${MENU_OPTS[@]}"; do
pad=$(( 36 - ${#opt} ))
if [ "$i" -eq "$sel" ]; then
printf '│ \033[1;34m▸ %s. %s\033[0m%*s│\n' "$((i+1))" "$opt" "$pad" ""
else
printf '│ %s. %s%*s│\n' "$((i+1))" "$opt" "$pad" ""
fi
i=$((i+1))
done
echo "└──────────────────────────────────────────────┘"
echo ""
echo " Flechas + Enter · numero + Enter · q/ESC salir"
if ! read -rsn1 key; then
print_error "Sin entrada disponible."
return 0
fi
if [ "$key" = $'\x1b' ]; then
rest=""
read -rsn2 -t 0.001 rest || true
case "$rest" in
'[A') sel=$(( (sel - 1 + n) % n )) ;;
'[B') sel=$(( (sel + 1) % n )) ;;
*) return 0 ;; # ESC sin flecha: salir
esac
elif [ "$key" = "" ]; then
# Enter: seleccionar la opcion marcada
[ "$sel" -eq $((n-1)) ] && return 0
return $((sel+1))
elif [[ "$key" =~ ^[0-9]$ ]]; then
# Atajo numerico: 1..5 seleccionan, 0 sale
[ "$key" = "0" ] && return 0
if [ "$key" -ge 1 ] && [ "$key" -le $((n-1)) ]; then
return "$key"
fi
elif [ "$key" = "q" ]; then
return 0
fi
done
}
+33 -1
View File
@@ -53,6 +53,33 @@ while [ $# -gt 0 ]; do
shift
done
# Menu (Pure-bash ANSI, cero dependencias): la entrada por defecto; los flags la bypassan
MODE="full"
if [ "$ASSUME_YES" != true ] && [ "$FORCE_NO_GPU" != true ]; then
source "$CORE_DIR/menu.sh"
sel=0
show_menu || sel=$?
case "$sel" in
0)
print_step "Hasta pronto."
exit 0
;;
1) : ;;
2) MODE="neo" ;;
3) MODE="openvino" ;;
4)
source "$CORE_DIR/doctor.sh"
run_doctor_checks
exit 0
;;
5)
source "$CORE_DIR/uninstall.sh"
run_uninstall
exit 0
;;
esac
fi
# privileges
if [ "$EUID" -ne 0 ]; then
echo "ERROR: This script must be run as root. Use:"
@@ -141,7 +168,7 @@ fi
# ------------------------------------------------------------------------------
# 3. Install NEO (only if there is a GPU)
# ------------------------------------------------------------------------------
if [ "$GPU_PRESENT" = true ]; then
if [ "$MODE" != "openvino" ] && [ "$GPU_PRESENT" = true ]; then
print_step "3. Installing GPU drivers (Intel Compute Runtime NEO)..."
case "$OS_ID" in
debian)
@@ -158,6 +185,11 @@ else
print_step "3. Skipping NEO driver installation (no Intel GPU)."
fi
if [ "$MODE" = "neo" ]; then
print_step "Instalacion NEO finalizada."
exit 0
fi
# ------------------------------------------------------------------------------
# 4. Download OpenVINO Runtime
# ------------------------------------------------------------------------------