Files
LazyPM/cmd/survey/forms/intro.go
Robin Olsen 90dd69a019 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
2026-02-08 15:03:45 +01:00

57 lines
1000 B
Go

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()
}