Menu System - Dialog Tool
The dev-setup menu uses dialog - a tool for creating text-based user interfaces (TUI) in shell scripts.
Why Dialog?β
| Feature | Benefit |
|---|---|
| Terminal-based | Works in SSH, containers, any terminal |
| Keyboard navigation | Arrow keys, Tab, Enter for navigation |
| No dependencies | Part of most Linux distributions |
| Accessible | Works with screen readers |
| Scriptable | Captures user input via exit codes and stdout |
Dialog Installationβ
Dialog is installed in the base devcontainer image (Dockerfile.base):
RUN apt-get update && apt-get install -y dialog
Dialog Widgetsβ
1. Menu Widget (--menu)β
Primary navigation - single selection from a list:
choice=$(dialog --clear \
--title "Main Menu" \
--menu "Choose an option:" \
20 80 12 \ # height width menu-height
"1" "Browse & Install Tools" \
"2" "Manage Services" \
"3" "Setup & Configuration" \
2>&1 >/dev/tty)
2. Menu with Item Help (--item-help)β
Adds context-sensitive help text at bottom of screen:
choice=$(dialog --clear \
--item-help \
--title "Select Tool" \
--menu "Choose a tool:" \
20 80 12 \
"1" "Go Runtime" "Install Go development environment" \
"2" "Python" "Install Python with pip and tools" \
2>&1 >/dev/tty)
3. Checklist Widget (--checklist)β
Multiple selection with on/off toggles:
selected=$(dialog --clear \
--title "Auto-Start Services" \
--checklist "Select services to auto-start:" \
20 80 12 \
"1" "Nginx Proxy" "on" \
"2" "OTEL Collector" "off" \
2>&1 >/dev/tty)
4. Input Box (--inputbox)β
Text input for parameters:
version=$(dialog --clear \
--title "Version" \
--inputbox "Enter Go version:" \
8 60 \
2>&1 >/dev/tty)
5. Message Box (--msgbox)β
Display information or errors:
dialog --title "Success" \
--msgbox "Installation complete!" \
8 50
6. Yes/No Dialog (--yesno)β
Confirmation prompts:
if dialog --title "Confirm" --yesno "Proceed with installation?" 8 50; then
# User said yes
fi
Dialog Output Handlingβ
Dialog writes selections to stderr (not stdout), so we redirect:
# Capture selection
choice=$(dialog ... 2>&1 >/dev/tty)
# Check exit code
if [[ $? -ne 0 ]]; then
# User pressed ESC or Cancel
return
fi
Dialog Dimensionsβ
Standard dimensions used in dev-setup.sh:
DIALOG_HEIGHT=20 # Total dialog height
DIALOG_WIDTH=80 # Total dialog width
MENU_HEIGHT=12 # Number of visible menu items
Status Icons in Menusβ
The system uses Unicode/emoji for status display:
| Icon | Meaning |
|---|---|
β
| Installed / Configured / Running |
β | Not installed / Not configured / Stopped |
βΈοΈ | Service stopped |
[AI], [DEV] | Category prefixes |
Referencesβ
- Dialog Manual
- Architecture - System architecture overview