add exit mechanicm to each stage

remove types and moved struct to appropriate files
This commit is contained in:
Robin Olsen
2026-02-16 13:08:45 +01:00
parent 1fe92d1972
commit b3b45e67be
7 changed files with 111 additions and 65 deletions

View File

@@ -7,6 +7,15 @@ import (
"github.com/charmbracelet/huh"
)
type Questions []*huh.Group
type QuestionnaireModel struct {
Questions
form *huh.Form
width, height int
userQuit bool
}
func NewQuestionnaireModel(questions Questions) *QuestionnaireModel {
form := huh.NewForm(questions...).
WithTheme(style.HuhCenterTheme()).WithLayout(huh.LayoutGrid(1, 1))
@@ -28,6 +37,7 @@ func (q *QuestionnaireModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case tea.KeyMsg:
switch msg.String() {
case "q", "ctrl+c":
q.userQuit = true
return q, tea.Quit
}
}
@@ -52,3 +62,7 @@ func (q *QuestionnaireModel) View() string {
func (q *QuestionnaireModel) SetSize(width, height int) {
q.width, q.height = width, height
}
func (q QuestionnaireModel) GetUserQuit() bool {
return q.userQuit
}