Local Development Setup
Relevant source files
The following files were used as context for generating this wiki page:
The Terminal Wizard project is a Go-based command-line interface (CLI) application built using the Bubble Tea TUI framework and Lip Gloss for styling. Its purpose is to guide users through a series of questions, capturing input through various specialized fields like short text entries and multi-line text areas.
Setting up the local development environment involves configuring the Go toolchain and ensuring the required dependencies from the Charm ecosystem (bubbles, bubbletea, lipgloss) are correctly installed. The application leverages an "AltScreen" mode to provide a full-screen interactive experience within the terminal.
Sources: README.md:1-12, main.go:121-125
Environment Requirements
To develop and run the Terminal Wizard, the following core technologies and libraries must be present in the development environment:
| Requirement | Description | Source |
|---|---|---|
| Go | The primary programming language used for the project. | main.go:1 |
| Bubble Tea | The Elm-architecture-based framework for TUI handling. | main.go:8, README.md:11 |
| Lip Gloss | Used for defining terminal styles and layouts. | main.go:9, README.md:12 |
| Bubbles | Specialized components like textinput and textarea. | input.go:4-5 |
Sources: main.go:8-9, input.go:4-5, README.md:11-12
Core Application Architecture
The application follows the Model-View-Update (MVU) pattern. The Main struct acts as the central state controller, managing a collection of Question objects and the current navigation state.
Program Initialization
When the application starts, it initializes a sequence of questions and styles before launching the Bubble Tea program loop. It also sets up a local logging mechanism for debugging.
The application uses tea.WithAltScreen() to capture the full terminal window during execution.
Sources: main.go:111-127
Component Relationship
The Main model contains the overall state, while the Input interface allows for polymorphic handling of different question types (short vs. long).
Sources: main.go:21-34, input.go:8-16
UI and Styling Configuration
The local setup uses a Styles struct to define the visual appearance of the terminal wizard. This centralizes configuration for borders and padding.
| Configuration | Type | Default Value | Description |
|---|---|---|---|
BorderColor | lipgloss.Color | "36" (Teal/Cyan) | Color used for input field borders. |
InputField | lipgloss.Style | NormalBorder, Padding 1, Width 80 | Layout settings for the user input area. |
The View() function uses lipgloss.Place to center the application content both horizontally and vertically based on the terminal window dimensions captured via tea.WindowSizeMsg.
Sources: main.go:13-20, main.go:76-80, main.go:95-107
Input Handling Logic
The application supports two types of input fields wrapped in the Input interface. This allows the Update loop to process messages regardless of the specific UI component being used.
Input Types and Constructors
- Short Answer: Uses
textinput.Modelfor single-line entries. Created vianewShortQuestion. - Long Answer: Uses
textarea.Modelfor multi-line entries. Created vianewLongQuestion.
Sources: main.go:41-55, input.go:18-100
Interaction Flow
When a user interacts with the wizard, the following sequence occurs to transition between questions:
Sources: main.go:73-82, input.go:11-16
Debugging and Development Tools
For local development, the project includes a built-in logging mechanism. This is critical because standard output (fmt.Println) is often obscured by the TUI's "AltScreen" rendering.
- Log File:
debug.log - Implementation:
tea.LogToFile("debug.log", "debug") - Execution: The file is created in the working directory when
main()is executed.
Sources: main.go:118-123
Summary
Setting up the Terminal Wizard locally requires a Go environment with the Bubble Tea and Lip Gloss libraries. The system is architected around a central Main model that iterates through Question objects, delegating specific input behavior to an Input interface. Developers can monitor application state and TUI events by checking the generated debug.log file during local execution.