Refactor: Verschachtelung im Ollama-Speicherort-Dialog reduziert
Der whiptail-Zweig verschachtelte vier Ebenen tief und verteilte drei identische chosen="$default_path"-Zuweisungen über if/else-Paare, um eine einzige lineare Entscheidung abzubilden. Die Ja/Nein-Abfrage und der Eingabedialog folgen jetzt beide dem Guard-Clause-Muster (if [[ -z "$chosen" ]]; then ... fi), das bereits für den CLI-Fallback weiter unten in derselben Funktion verwendet wird. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017WMUd2fGsPCtTCVQkSS5TA
This commit is contained in:
+9
-15
@@ -280,30 +280,24 @@ prompt_ollama_models_path() {
|
|||||||
--yesno "Standard-Speicherort für Ollama-Modelle:\n\n$default_path\n\nMöchtest du diesen Speicherort verwenden?" \
|
--yesno "Standard-Speicherort für Ollama-Modelle:\n\n$default_path\n\nMöchtest du diesen Speicherort verwenden?" \
|
||||||
12 70 || yesno_status=$?
|
12 70 || yesno_status=$?
|
||||||
if [[ "$yesno_status" -eq 0 || "$yesno_status" -eq 255 ]]; then
|
if [[ "$yesno_status" -eq 0 || "$yesno_status" -eq 255 ]]; then
|
||||||
# Yes, or ESC/Cancel (255) - fall back to the configured
|
# Yes, or ESC/Cancel (255) - use the configured default,
|
||||||
# default, consistent with the inputbox dialog below where
|
# consistent with the inputbox fallback below where an
|
||||||
# ESC/Cancel also keeps the default instead of asking again.
|
# empty or cancelled dialog also keeps the default instead
|
||||||
|
# of asking again.
|
||||||
chosen="$default_path"
|
chosen="$default_path"
|
||||||
else
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$chosen" ]]; then
|
||||||
local tui_tmp
|
local tui_tmp
|
||||||
tui_tmp="$(mktemp)"
|
tui_tmp="$(mktemp)"
|
||||||
if run_whiptail --output-fd 3 --title "Ollama KI-Modelle Speicherort" \
|
if run_whiptail --output-fd 3 --title "Ollama KI-Modelle Speicherort" \
|
||||||
--inputbox "Bitte gib den Speicherort für die Ollama KI-Modelle an:" \
|
--inputbox "Bitte gib den Speicherort für die Ollama KI-Modelle an:" \
|
||||||
10 70 "$default_path" \
|
10 70 "$default_path" \
|
||||||
3> "$tui_tmp"; then
|
3> "$tui_tmp"; then
|
||||||
local tui_input
|
chosen="$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' < "$tui_tmp")"
|
||||||
tui_input="$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' < "$tui_tmp")"
|
|
||||||
if [[ -n "$tui_input" ]]; then
|
|
||||||
chosen="$tui_input"
|
|
||||||
else
|
|
||||||
chosen="$default_path"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# Dialog cancelled - fall back to the configured default
|
|
||||||
# instead of dropping into the CLI prompt below too.
|
|
||||||
chosen="$default_path"
|
|
||||||
fi
|
fi
|
||||||
rm -f "$tui_tmp"
|
rm -f "$tui_tmp"
|
||||||
|
[[ -z "$chosen" ]] && chosen="$default_path"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user