feat(F98-I2): UX-Bündel B8-B11 — ask_with_help + [H]-Hilfe + J/N-Konsistenz
B9: ask_with_help() Helper — Ja/Nein-Frage mit [H]-Hilfstext.
H/? zeigt help_text und fragt erneut; J/j/Y/y/1 → true, N/n/0 → false,
Enter → default. Suffix sprachabhängig (DE [J/N/H], EN [Y/N/H]).
B10: Sprach-Pack erweitert um multiroom_help, profile_q, profile_help,
ask_suffix (DE/EN). Multiroom-Frage mit ein-Satz-Erklärung.
B8: Profil-Frage selbsterklärend (P/T + [H]-Hilfe) via while-Schleife.
B11: DE-Dialoge auf J)/N() umgestellt (EN behält Y/N).
Tests: test_f98_i2.py um TestAskWithHelp erweitert (7 Tests). 89 passed.
Branch main @ 3aa1c5a. KEIN Push, KEIN Deploy.
This commit is contained in:
+77
-8
@@ -2716,12 +2716,24 @@ T[de_lang_q]="Bitte Sprache wählen / Please select language: 1) Deutsch 2) En
|
||||
T[en_lang_q]="Please select language: 1) Deutsch 2) English"
|
||||
T[de_lang_ok]="Sprache: Deutsch"
|
||||
T[en_lang_ok]="Language: English"
|
||||
T[de_multiroom_q]="Wird ein Multiroom-Agent benötigt? Y) Ja — Bot routet mehrere Themenräume (Archivar aktiv) N) Nein — Single-Room-Modus (nur 1 Raum, Archivar deaktiviert)"
|
||||
T[en_multiroom_q]="Do you need a multiroom agent? Y) Yes — bot routes multiple topic rooms (Archivar active) N) No — single-room mode (1 room only, Archivar disabled)"
|
||||
T[de_multiroom_q]="Wird ein Multiroom-Agent benötigt?
|
||||
Ein Multiroom-Agent routet eingehende Nachrichten automatisch in den
|
||||
passenden Themenraum (Archivar aktiv). H) Hilfe J) Ja N) Nein"
|
||||
T[en_multiroom_q]="Do you need a multiroom agent?
|
||||
A multiroom agent routes incoming messages automatically to the matching
|
||||
topic room (Archivar active). H) Help Y) Yes N) No"
|
||||
T[de_multiroom_help]="Multiroom: Bot kennt alle Themenräume und entscheidet automatisch, wohin jede Nachricht gehört. Single-Room: Bot arbeitet nur in einem Raum (z.B. DM), keine Routing-Logik nötig."
|
||||
T[en_multiroom_help]="Multiroom: the bot knows all topic rooms and decides automatically where each message belongs. Single-room: the bot works in one room only (e.g. DM), no routing logic needed."
|
||||
T[de_multiroom_ok]="Multiroom: Ja"
|
||||
T[en_multiroom_ok]="Multiroom: Yes"
|
||||
T[de_multiroom_no]="Multiroom: Nein (Single-Room-Modus)"
|
||||
T[en_multiroom_no]="Multiroom: No (single-room mode)"
|
||||
T[de_profile_q]="Welches Profil? P) Produktion (24/7, Auto-Update) T) Test/Dev (manuell) H) Hilfe"
|
||||
T[en_profile_q]="Which profile? P) Production (24/7, auto-update) T) Test/Dev (manual) H) Help"
|
||||
T[de_profile_help]="Produktion: Bot läuft durchgehend, Updates automatisch. Test/Dev: Bot nur bei Bedarf starten, Updates manuell via --update-only."
|
||||
T[en_profile_help]="Production: bot runs continuously, updates automatic. Test/Dev: start the bot only when needed, update manually via --update-only."
|
||||
T[de_ask_suffix]=" [J/N/H]: "
|
||||
T[en_ask_suffix]=" [Y/N/H]: "
|
||||
T[de_rc_url_q]="Rocket.Chat-Server-URL?"
|
||||
T[en_rc_url_q]="Rocket.Chat server URL?"
|
||||
T[de_rc_user_q]="Bot-Username?"
|
||||
@@ -2784,6 +2796,48 @@ ask() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# ── F98 B9 — ask_with_help(): Ja/Nein-Frage mit [H]-Hilfstext. ──
|
||||
# ask_with_help <var_name> "<question>" "<default>" "<help_text>"
|
||||
# Setzt <var_name> auf "true" oder "false".
|
||||
# - H oder ?: zeigt help_text, dann Frage erneut
|
||||
# - J/j/Y/y/1: true
|
||||
# - N/n/0: false
|
||||
# - Default (Enter): <default>
|
||||
# Suffix ist sprachabhängig (DE: [J/N/H], EN: [Y/N/H]).
|
||||
# ──────────────────────────────────────────────────────────────────────────
|
||||
ask_with_help() {
|
||||
local varname="$1" question="$2" default="$3" help_text="$4"
|
||||
local suffix="${T[${LANG_CHOICE}_ask_suffix]:-${T[de_ask_suffix]}}"
|
||||
local val="$default"
|
||||
|
||||
if $GUIDED_DEFAULTS; then
|
||||
printf '%s[guided-defaults]%s %s = %s\n' "$C_YELLOW" "$C_RESET" "$varname" "$val"
|
||||
eval "$varname=\"$val\""
|
||||
return 0
|
||||
fi
|
||||
|
||||
while true; do
|
||||
printf '%s[?]%s %s%s' "$C_BLUE" "$C_RESET" "$question" "$suffix"
|
||||
local input
|
||||
read -r input
|
||||
case "$input" in
|
||||
H|h|'?')
|
||||
printf '%s[i]%s %s\n' "$C_BLUE" "$C_RESET" "$help_text"
|
||||
continue
|
||||
;;
|
||||
J|j|Y|y|1) val="true"; break ;;
|
||||
N|n|0) val="false"; break ;;
|
||||
'')
|
||||
[ -n "$default" ] && val="$default"
|
||||
break
|
||||
;;
|
||||
*) continue ;;
|
||||
esac
|
||||
done
|
||||
eval "$varname=\"$val\""
|
||||
return 0
|
||||
}
|
||||
|
||||
# ── Wizard-Hauptfunktion. Führt Phasen 0-11 aus, setzt env-Variablen. ──
|
||||
run_guided_wizard() {
|
||||
banner "Hermes Rocket.Chat Plugin — Geführte Installation (F98)"
|
||||
@@ -2854,7 +2908,20 @@ run_guided_wizard() {
|
||||
if phase_done 2; then
|
||||
ok "[Phase 2 übersprungen (bereits abgeschlossen)]"
|
||||
else
|
||||
ask PROFILE "Welches Profil? 1) Produktion (24/7) 2) Test/Dev" "1" false
|
||||
# F98 B8: Profil-Frage selbsterklärend machen (P/T + [H]-Hilfe).
|
||||
local _profile_done=false
|
||||
while ! $_profile_done; do
|
||||
ask PROFILE "${T[${LANG_CHOICE}_profile_q]}" "1" false
|
||||
case "$PROFILE" in
|
||||
H|h|'?')
|
||||
printf '%s[i]%s %s\n' "$C_BLUE" "$C_RESET" "${T[${LANG_CHOICE}_profile_help]}"
|
||||
continue
|
||||
;;
|
||||
P|p|1) PROFILE="1"; _profile_done=true ;;
|
||||
T|t|2) PROFILE="2"; _profile_done=true ;;
|
||||
*) _profile_done=true ;;
|
||||
esac
|
||||
done
|
||||
if [ "$PROFILE" = "2" ]; then
|
||||
LOG_LEVEL="DEBUG"; ROCKETCHAT_PING_SEC="3"; ROCKETCHAT_IDLE_SEC="300"
|
||||
else
|
||||
@@ -2868,11 +2935,13 @@ run_guided_wizard() {
|
||||
if phase_done 3; then
|
||||
ok "[Phase 3 übersprungen (bereits abgeschlossen)]"
|
||||
else
|
||||
ask MULTIROOM_ANS "Wird ein Multiroom-Agent benötigt? Y) Ja N) Nein" "N" false
|
||||
case "$MULTIROOM_ANS" in
|
||||
Y|y|J|j|1) RC_MULTIROOM="true"; ok "[${T[${LANG_CHOICE}_multiroom_ok]}]" ;;
|
||||
*) RC_MULTIROOM="false"; ok "[${T[${LANG_CHOICE}_multiroom_no]}]" ;;
|
||||
esac
|
||||
# F98 B10/B11: Multiroom-Frage mit Erklärung + [H]-Hilfe + J/N-Konsistenz.
|
||||
ask_with_help MULTIROOM_ANS "${T[${LANG_CHOICE}_multiroom_q]}" "false" "${T[${LANG_CHOICE}_multiroom_help]}"
|
||||
if [ "$MULTIROOM_ANS" = "true" ]; then
|
||||
RC_MULTIROOM="true"; ok "[${T[${LANG_CHOICE}_multiroom_ok]}]"
|
||||
else
|
||||
RC_MULTIROOM="false"; ok "[${T[${LANG_CHOICE}_multiroom_no]}]"
|
||||
fi
|
||||
mark_phase 3 "multiroom"
|
||||
fi
|
||||
|
||||
|
||||
@@ -208,3 +208,86 @@ class TestRepairUnitMissing:
|
||||
def test_repair_components_has_stage_8(self):
|
||||
content = _read_install_sh()
|
||||
assert "Reparatur Stufe 8" in content
|
||||
|
||||
|
||||
class TestAskWithHelp:
|
||||
"""B9/B10/B11: ask_with_help() — [H]-Hilfe + J/N-Konsistenz."""
|
||||
|
||||
def test_ask_with_help_function_exists(self):
|
||||
content = _read_install_sh()
|
||||
assert "ask_with_help()" in content
|
||||
|
||||
def test_ask_with_help_yes(self):
|
||||
snippet = (
|
||||
_extract_functions("ask_with_help")
|
||||
+ "GUIDED_DEFAULTS=false\n"
|
||||
+ "LANG_CHOICE='de'\n"
|
||||
+ "declare -A T\n"
|
||||
+ "T[de_ask_suffix]=' [J/N/H]: '\n"
|
||||
+ "ask_with_help MY_VAR 'Frage?' 'false' 'Hilfetext' <<< 'J'\n"
|
||||
+ "echo \"MY_VAR=$MY_VAR\"\n"
|
||||
)
|
||||
out, err, rc = _run_bash(snippet)
|
||||
assert rc == 0, f"ask_with_help crashte:\n{out}\n{err}"
|
||||
assert "MY_VAR=true" in out, f"J sollte true setzen:\n{out}"
|
||||
|
||||
def test_ask_with_help_no(self):
|
||||
snippet = (
|
||||
_extract_functions("ask_with_help")
|
||||
+ "GUIDED_DEFAULTS=false\n"
|
||||
+ "LANG_CHOICE='de'\n"
|
||||
+ "declare -A T\n"
|
||||
+ "T[de_ask_suffix]=' [J/N/H]: '\n"
|
||||
+ "ask_with_help MY_VAR 'Frage?' 'true' 'Hilfetext' <<< 'N'\n"
|
||||
+ "echo \"MY_VAR=$MY_VAR\"\n"
|
||||
)
|
||||
out, err, rc = _run_bash(snippet)
|
||||
assert rc == 0
|
||||
assert "MY_VAR=false" in out, f"N sollte false setzen:\n{out}"
|
||||
|
||||
def test_ask_with_help_shows_help_then_accepts(self):
|
||||
"""H zeigt Hilfe, dann J wird akzeptiert."""
|
||||
snippet = (
|
||||
_extract_functions("ask_with_help")
|
||||
+ "GUIDED_DEFAULTS=false\n"
|
||||
+ "LANG_CHOICE='de'\n"
|
||||
+ "declare -A T\n"
|
||||
+ "T[de_ask_suffix]=' [J/N/H]: '\n"
|
||||
+ "ask_with_help MY_VAR 'Frage?' 'false' 'HILFETEXT-MARKER' <<< $'H\\nJ'\n"
|
||||
+ "echo \"MY_VAR=$MY_VAR\"\n"
|
||||
)
|
||||
out, err, rc = _run_bash(snippet)
|
||||
assert rc == 0
|
||||
assert "HILFETEXT-MARKER" in out, f"H sollte Hilfe zeigen:\n{out}\n{err}"
|
||||
assert "MY_VAR=true" in out, f"J nach H sollte true setzen:\n{out}"
|
||||
|
||||
def test_ask_with_help_default_on_empty(self):
|
||||
snippet = (
|
||||
_extract_functions("ask_with_help")
|
||||
+ "GUIDED_DEFAULTS=false\n"
|
||||
+ "LANG_CHOICE='de'\n"
|
||||
+ "declare -A T\n"
|
||||
+ "T[de_ask_suffix]=' [J/N/H]: '\n"
|
||||
+ "ask_with_help MY_VAR 'Frage?' 'true' 'Hilfetext' <<< ''\n"
|
||||
+ "echo \"MY_VAR=$MY_VAR\"\n"
|
||||
)
|
||||
out, err, rc = _run_bash(snippet)
|
||||
assert rc == 0
|
||||
assert "MY_VAR=true" in out, f"Default sollte bei leerer Eingabe greifen:\n{out}"
|
||||
|
||||
def test_language_pack_has_help_keys(self):
|
||||
content = _read_install_sh()
|
||||
assert "T[de_multiroom_help]" in content
|
||||
assert "T[en_multiroom_help]" in content
|
||||
assert "T[de_profile_help]" in content
|
||||
assert "T[en_profile_help]" in content
|
||||
assert "T[de_ask_suffix]" in content
|
||||
assert "T[en_ask_suffix]" in content
|
||||
|
||||
def test_de_uses_jn_not_yn(self):
|
||||
"""B11: DE-Dialoge nutzen J)/N(), nicht Y)/N()."""
|
||||
content = _read_install_sh()
|
||||
# Der DE-Multiroom-Text darf kein Y) mehr enthalten.
|
||||
assert "J) Ja" in content
|
||||
# EN behält Y/N (korrekt).
|
||||
assert "Y) Yes" in content
|
||||
|
||||
Reference in New Issue
Block a user