Alle Fenster ueber drei gemeinsame Stellen, Selbstpruefung dazu
Die berechnete Fenstergroesse galt bisher nur fuer die Dialoge, die ich
dafuer einzeln angefasst hatte. Eine Pruefung des ganzen Projekts zeigte
zwei Luecken:
* in common.sh gab es neun verstreute Aufrufstellen von dialog/whiptail
* migrate_creator.sh hatte noch durchgehend feste Groessen
(20 76 11, 10 76, 18 76, 14 76, 22 78, 8 76)
Beide Skripte rufen dialog/whiptail jetzt nur noch ueber drei Stellen auf:
_ui_list Listenfenster (menu, checklist, radiolist)
_ui_box Textfenster (msgbox, yesno, inputbox, passwordbox, infobox)
_ui_file Dateianzeige (textbox)
Die berechnen die Groesse selbst. Damit stimmt sie auch fuer Fenster, die
spaeter dazukommen - man muss nur eine der ui_*-Huellen benutzen.
Neu: "cmk-manage.sh selftest" haelt das nach. Geprueft werden Syntax
aller vier Skripte, Dialoge an den Engstellen vorbei, fest eingetragene
Fenstergroessen, das Muster "[ ... ] && VAR=..." und die Vollstaendigkeit
der Einstellungstabelle gegenueber .env.example.
Der Lauf fand sofort 19 Altlasten des Musters "[ ... ] && VAR=...", das
hier schon dreimal einen stillen Abbruch verursacht hat - alle in
if-Bloecke umgeschrieben und stichprobenartig geprueft, auch die Faelle
mit case-Abschluss und Array-Zuweisung. Danach laeuft die Selbstpruefung
vollstaendig durch.
Regression: alle CLI-Kommandos, zwoelf Menuefunktionen und das Rendern
von sechs Fenstern unter whiptail in einem echten Pseudo-Terminal.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+51
-52
@@ -317,75 +317,74 @@ ui_require() {
|
||||
UI_BACKTITLE="Checkmk Stack Manager - Runtime: $RUNTIME"
|
||||
}
|
||||
|
||||
ui_menu() { # title text tag item [tag item ...] -> gewaehlter tag auf stdout
|
||||
# =====================================================================
|
||||
# Alle Dialoge laufen ueber genau drei Engstellen.
|
||||
#
|
||||
# Damit stimmt die Fenstergroesse automatisch - auch fuer Dialoge, die
|
||||
# spaeter dazukommen. NEUE FENSTER BITTE IMMER UEBER DIESE DREI BAUEN
|
||||
# und niemals "$UI_BIN" direkt aufrufen; "cmk-manage.sh selftest"
|
||||
# prueft das nach.
|
||||
#
|
||||
# _ui_list Listenfenster (menu, checklist, radiolist) -> ui_calc
|
||||
# _ui_box Textfenster (msgbox, yesno, inputbox, ...) -> ui_calc_text
|
||||
# _ui_file Dateianzeige (textbox) -> volles Bild
|
||||
# =====================================================================
|
||||
|
||||
# _ui_list WIDGET TITEL TEXT FELDER_JE_EINTRAG EINTRAEGE...
|
||||
_ui_list() {
|
||||
ui_init
|
||||
local title="$1" text="$2"; shift 2
|
||||
ui_calc "$text" 2 "$@"
|
||||
local widget="$1" title="$2" text="$3" per="$4"; shift 4
|
||||
ui_calc "$text" "$per" "$@"
|
||||
"$UI_BIN" --backtitle "$UI_BACKTITLE" --title "$title" \
|
||||
--menu "$text" "$UI_H" "$UI_W" "$UI_MH" "$@" 3>&1 1>&2 2>&3
|
||||
"$widget" "$text" "$UI_H" "$UI_W" "$UI_MH" "$@" 3>&1 1>&2 2>&3
|
||||
}
|
||||
|
||||
ui_checklist() { # title text tag item status ...
|
||||
# _ui_box WIDGET TITEL TEXT ZUSATZZEILEN [weitere Argumente]
|
||||
# Widgets ohne Rueckgabe (msgbox, yesno, infobox) liefern nur den Status.
|
||||
_ui_box() {
|
||||
ui_init
|
||||
local title="$1" text="$2"; shift 2
|
||||
ui_calc "$text" 3 "$@"
|
||||
"$UI_BIN" --backtitle "$UI_BACKTITLE" --title "$title" \
|
||||
--checklist "$text" "$UI_H" "$UI_W" "$UI_MH" "$@" 3>&1 1>&2 2>&3
|
||||
local widget="$1" title="$2" text="$3" extra="$4"; shift 4
|
||||
ui_calc_text "$text" "$extra"
|
||||
case "$widget" in
|
||||
--inputbox|--passwordbox)
|
||||
"$UI_BIN" --backtitle "$UI_BACKTITLE" --title "$title" \
|
||||
"$widget" "$text" "$UI_H" "$UI_W" "$@" 3>&1 1>&2 2>&3 ;;
|
||||
*)
|
||||
"$UI_BIN" --backtitle "$UI_BACKTITLE" --title "$title" \
|
||||
"$widget" "$text" "$UI_H" "$UI_W" "$@" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
ui_radiolist() {
|
||||
ui_init
|
||||
local title="$1" text="$2"; shift 2
|
||||
ui_calc "$text" 3 "$@"
|
||||
"$UI_BIN" --backtitle "$UI_BACKTITLE" --title "$title" \
|
||||
--radiolist "$text" "$UI_H" "$UI_W" "$UI_MH" "$@" 3>&1 1>&2 2>&3
|
||||
}
|
||||
|
||||
ui_input() { # title text default
|
||||
ui_init
|
||||
ui_calc_text "$2" 10
|
||||
"$UI_BIN" --backtitle "$UI_BACKTITLE" --title "$1" \
|
||||
--inputbox "$2" "$UI_H" "$UI_W" "${3:-}" 3>&1 1>&2 2>&3
|
||||
}
|
||||
|
||||
ui_password() {
|
||||
ui_init
|
||||
ui_calc_text "$2" 10
|
||||
"$UI_BIN" --backtitle "$UI_BACKTITLE" --title "$1" \
|
||||
--passwordbox "$2" "$UI_H" "$UI_W" 3>&1 1>&2 2>&3
|
||||
}
|
||||
|
||||
ui_msg() { # title text
|
||||
ui_init
|
||||
ui_calc_text "$2" 7
|
||||
"$UI_BIN" --backtitle "$UI_BACKTITLE" --title "$1" --msgbox "$2" "$UI_H" "$UI_W"
|
||||
}
|
||||
|
||||
ui_yesno() { # title text -> exit 0 = ja
|
||||
ui_init
|
||||
ui_calc_text "$2" 8
|
||||
"$UI_BIN" --backtitle "$UI_BACKTITLE" --title "$1" --yesno "$2" "$UI_H" "$UI_W"
|
||||
}
|
||||
|
||||
ui_text() { # title file - so gross wie das Terminal es zulaesst
|
||||
# _ui_file TITEL DATEI - nutzt das Terminal so weit wie moeglich aus
|
||||
_ui_file() {
|
||||
ui_init
|
||||
ui_term_size
|
||||
"$UI_BIN" --backtitle "$UI_BACKTITLE" --title "$1" --textbox "$2" \
|
||||
$(( UI_ROWS - 2 )) $(( UI_COLS - 4 ))
|
||||
"$UI_BIN" --backtitle "$UI_BACKTITLE" --title "$1" \
|
||||
--textbox "$2" $(( UI_ROWS - 2 )) $(( UI_COLS - 4 ))
|
||||
}
|
||||
|
||||
ui_info() { # title text (ohne OK-Button)
|
||||
ui_init
|
||||
ui_calc_text "$2" 5
|
||||
"$UI_BIN" --backtitle "$UI_BACKTITLE" --title "$1" --infobox "$2" "$UI_H" "$UI_W"
|
||||
}
|
||||
# ---------------------------------------------------------------------
|
||||
# Die eigentlichen Dialoge - alle nur noch duenne Huellen
|
||||
# ---------------------------------------------------------------------
|
||||
ui_menu() { local t="$1" x="$2"; shift 2; _ui_list --menu "$t" "$x" 2 "$@"; }
|
||||
ui_checklist() { local t="$1" x="$2"; shift 2; _ui_list --checklist "$t" "$x" 3 "$@"; }
|
||||
ui_radiolist() { local t="$1" x="$2"; shift 2; _ui_list --radiolist "$t" "$x" 3 "$@"; }
|
||||
|
||||
ui_input() { _ui_box --inputbox "$1" "$2" 10 "${3:-}"; }
|
||||
ui_password() { _ui_box --passwordbox "$1" "$2" 10; }
|
||||
ui_msg() { _ui_box --msgbox "$1" "$2" 7; }
|
||||
ui_yesno() { _ui_box --yesno "$1" "$2" 8; }
|
||||
ui_info() { _ui_box --infobox "$1" "$2" 5; }
|
||||
ui_text() { _ui_file "$1" "$2"; }
|
||||
|
||||
# Kommando ausfuehren, Ausgabe live in Datei, danach in Textbox anzeigen
|
||||
ui_run() { # title cmd...
|
||||
ui_init
|
||||
local title="$1"; shift
|
||||
local logf; logf="$(mktemp)"
|
||||
ui_info "$title" "Bitte warten ...\n\n$*"
|
||||
ui_info "$title" "Bitte warten ...
|
||||
|
||||
$*"
|
||||
if "$@" >"$logf" 2>&1; then
|
||||
ui_text "$title - erfolgreich" "$logf"
|
||||
rm -f "$logf"; return 0
|
||||
|
||||
Reference in New Issue
Block a user