add introduction to the survey

add lib to read toml files
embed fs for reading toml files
add form for introduction
add form for choosing interface
This commit is contained in:
Robin Olsen
2026-02-08 15:03:45 +01:00
parent 0d9acdee93
commit 90dd69a019
6 changed files with 141 additions and 44 deletions

56
cmd/survey/forms/intro.go Normal file
View File

@@ -0,0 +1,56 @@
package forms
import (
"embed"
"fmt"
"github.com/BurntSushi/toml"
"github.com/charmbracelet/huh"
)
type Introduction struct {
Title string
Description string
About struct {
Title string
Description string
}
Disclaimer struct {
Title string
Description string
}
}
func NewIntroduction(fs embed.FS) (Introduction, error) {
var intro Introduction
if _, err := toml.DecodeFS(fs, "assets/intro.toml", &intro); err != nil {
return Introduction{}, err
}
return intro, nil
}
func (i Introduction) Run() error {
fmt.Print("\033[H\033[2J")
form := huh.NewForm(
huh.NewGroup(
huh.NewNote().
Title(i.Title).
Description(i.Description),
),
huh.NewGroup(
huh.NewNote().
Title(i.About.Title).
Description(i.About.Description),
),
huh.NewGroup(
huh.NewNote().
Title(i.Disclaimer.Title).
Description(i.Disclaimer.Description),
),
).WithLayout(huh.LayoutStack).
WithTheme(huh.ThemeBase16())
return form.Run()
}