Documentation
¶
Overview ¶
Package tui provides a text-based user interface for the application.
Index ¶
- Variables
- func CommitMessageTextArea() (string, error)
- func IsInteractive() bool
- func MustPromptForInputTea(prompt string) string
- func MustPromptWithChoices(question string, choices []string) string
- func MustPromptYesNoTea(question string, defaultChoice bool) bool
- func SpinnerStart(text string)
- func SpinnerStop()
- type ChoiceModel
- type InputModel
- type SpinnerModel
- type TextAreaModel
Constants ¶
This section is empty.
Variables ¶
var ( ChoiceStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FFFFFF")) CursorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#00FF00")) HintStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#767676")) InputStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#00FF00")) QuestionStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF06B7")).Bold(true) )
Style definitions.
Functions ¶
func CommitMessageTextArea ¶
CommitMessageTextArea is an entry function to interact with the text area model.
func IsInteractive ¶ added in v0.2.0
func IsInteractive() bool
IsInteractive reports whether the process is attached to a terminal on both ends, which is what Bubble Tea needs: one to render to and one to read keystrokes from. Bubble Tea falls back to the controlling terminal when stdin is redirected, so that counts too. When it returns false the spinner degrades to plain status lines and the interactive prompts cannot run.
func MustPromptForInputTea ¶
MustPromptForInputTea prompts the user for input using the BubbleTea framework. This function encapsulates the process of setting up, running, and managing the life cycle of the prompt.
func MustPromptWithChoices ¶
MustPromptWithChoices prompts the user with multiple choices using Tea. Returns the selected choice as a string.
func MustPromptYesNoTea ¶
MustPromptYesNoTea prompts a yes/no question using Tea. Returns true for 'Yes' and false for 'No'.
func SpinnerStart ¶ added in v0.1.0
func SpinnerStart(text string)
SpinnerStart starts the spinner with the given text. Without a terminal (a git hook, a CI job, redirected stdin or stdout) it prints the text as a plain line instead, since Bubble Tea cannot run there.
Types ¶
type ChoiceModel ¶
type ChoiceModel struct {
// contains filtered or unexported fields
}
ChoiceModel holds the state for multiple-choice prompts. It manages the current selection, the list of choices, and the specific question being asked.
func (ChoiceModel) Init ¶
func (m ChoiceModel) Init() tea.Cmd
Init initializes the model. Returns a command but does nothing initially.
func (ChoiceModel) Update ¶
Update processes incoming messages and updates the model based on user input. Handles key presses to navigate and select from the choices.
func (ChoiceModel) View ¶
func (m ChoiceModel) View() string
View renders the UI components, showing the question and the list of choices.
type InputModel ¶
type InputModel struct {
// contains filtered or unexported fields
}
InputModel holds the state for text input prompts. It manages the text input field, any potential error state, the prompt message, and the final user input.
func (InputModel) Init ¶
func (m InputModel) Init() tea.Cmd
Init initializes the input model for the Tea framework. Here, it sets up the text input blinking for user interaction.
func (InputModel) Update ¶
Update serves as the state update function for the Tea framework. It processes incoming messages, which often stem from user input.
func (InputModel) View ¶
func (m InputModel) View() string
View returns the string that represents the current View of the program. It provides the prompt, the user input area, and a hint for submission.
type SpinnerModel ¶
type SpinnerModel struct {
// contains filtered or unexported fields
}
SpinnerModel contains the state and behavior of the spinner.
func (SpinnerModel) Init ¶
func (m SpinnerModel) Init() tea.Cmd
Init initializes the spinner, returning its initial command for starting the tick loop.
func (SpinnerModel) Update ¶
Update handles messages for spinner updates and potential quit requests.
func (SpinnerModel) View ¶
func (m SpinnerModel) View() string
View renders the spinner and associated text to be displayed.
type TextAreaModel ¶ added in v0.1.0
type TextAreaModel struct {
// contains filtered or unexported fields
}
Define a model for managing the state of the text area.
func (TextAreaModel) Init ¶ added in v0.1.0
func (m TextAreaModel) Init() tea.Cmd
Init initializes the text area model for the Tea framework.
func (TextAreaModel) Update ¶ added in v0.1.0
Update handles messages for updating the text area model.
func (TextAreaModel) View ¶ added in v0.1.0
func (m TextAreaModel) View() string
View method renders the current state of the model into a viewable string format.