tui

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionNew       = actionNew
	ActionTemplates = actionTemplates
	ActionGitHub    = actionGitHub
	ActionConfig    = actionConfig
)

Variables

View Source
var ErrMenuExit = errors.New("menu exited")

Functions

func ApplyDefault

func ApplyDefault(input dsl.Input, ctx dsl.Context) (string, error)

ApplyDefault returns the input's default value as a string. If the default is a string containing `{{ }}` interpolations, it will be interpolated.

func BuildContext

func BuildContext(inputs []dsl.Input, answers map[string]string) (dsl.Context, error)

BuildContext constructs a dsl.Context from inputs + an answers map. It evaluates each input `when:` in order, applies defaults when answers are missing, and applies `when: false` defaults regardless of provided answers.

func Run added in v0.1.5

func Run(templates []*template.Template, eng *engine.Engine) error

Run lanza la sesión TUI completa (welcome + menú + sub-pantallas).

func RunApp added in v0.1.2

func RunApp(templates []*tmpl.Template, eng *engine.Engine) error

func RunInputs

func RunInputs(inputs []dsl.Input) (dsl.Context, error)

RunInputs runs an interactive prompt for the provided manifest inputs.

func RunInputsWithInitial

func RunInputsWithInitial(inputs []dsl.Input, initial dsl.Context) (dsl.Context, error)

RunInputsWithInitial is like RunInputs but seeds the context with pre-filled values. This is used by the `structify new` command to support a mixed mode (flags + TUI).

func RunMenu added in v0.1.4

func RunMenu() (menuAction, error)

func RunProgress

RunProgress executes scaffolding while rendering a progress TUI.

func RunSelector

func RunSelector(templates []*template.Template) (*template.Template, error)

RunSelector shows a searchable list of templates and returns the selected one.

Edge cases: - if templates is empty => returns an actionable error - if only one template => returns it without launching TUI

func ShouldAskInput

func ShouldAskInput(input dsl.Input, ctx dsl.Context) (bool, error)

ShouldAskInput decides whether a given input should be prompted, based on its `when:` expression and the accumulated context.

func ShowSummary

func ShowSummary(result *template.ScaffoldResult, req *template.ScaffoldRequest)

ShowSummary prints a final summary after successful generation.

func ValidateInputValue

func ValidateInputValue(input dsl.Input, value string) error

ValidateInputValue validates a user-provided (string) value against the input definition. This includes `validate` regex when present.

func WelcomeView added in v0.1.4

func WelcomeView(width int) string

Types

type App added in v0.1.2

type App struct {
	// contains filtered or unexported fields
}

func (*App) Done added in v0.1.5

func (a *App) Done() bool

Done retorna true cuando el usuario presionó cualquier tecla en stateDone/stateError. Se usa por RootModel para volver al menú sin salir del programa.

func (*App) Init added in v0.1.2

func (a *App) Init() tea.Cmd

func (*App) Update added in v0.1.2

func (a *App) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*App) View added in v0.1.2

func (a *App) View() string

func (*App) ViewContent added in v0.1.6

func (a *App) ViewContent() string

ViewContent returns the raw (non-centered) content of this screen. RootModel is responsible for centering.

type ConfigModel added in v0.1.5

type ConfigModel struct {
	// contains filtered or unexported fields
}

func NewConfigModel added in v0.1.5

func NewConfigModel(templates []*template.Template) *ConfigModel

func (*ConfigModel) Init added in v0.1.5

func (m *ConfigModel) Init() tea.Cmd

func (*ConfigModel) Update added in v0.1.5

func (m *ConfigModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*ConfigModel) View added in v0.1.5

func (m *ConfigModel) View() string

func (*ConfigModel) ViewContent added in v0.1.6

func (m *ConfigModel) ViewContent() string

type GitHubModel added in v0.1.5

type GitHubModel struct {
	// contains filtered or unexported fields
}

func NewGitHubModel added in v0.1.5

func NewGitHubModel() *GitHubModel

func (*GitHubModel) Init added in v0.1.5

func (m *GitHubModel) Init() tea.Cmd

func (*GitHubModel) Update added in v0.1.5

func (m *GitHubModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*GitHubModel) View added in v0.1.5

func (m *GitHubModel) View() string

func (*GitHubModel) ViewContent added in v0.1.6

func (m *GitHubModel) ViewContent() string
type MenuAction = menuAction
type MenuModel struct {
	// contains filtered or unexported fields
}

func NewMenuModel added in v0.1.4

func NewMenuModel() MenuModel
func (m MenuModel) Init() tea.Cmd
func (m MenuModel) SelectedAction() menuAction
func (m MenuModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)
func (m MenuModel) View() string
func (m MenuModel) ViewContent() string

ViewContent returns the raw (non-centered) content of this screen. RootModel is responsible for applying any centering/alignment.

type RootModel added in v0.1.5

type RootModel struct {
	// contains filtered or unexported fields
}

func NewRootModel added in v0.1.5

func NewRootModel(templates []*template.Template, eng *engine.Engine) RootModel

func (RootModel) Init added in v0.1.5

func (r RootModel) Init() tea.Cmd

func (RootModel) Update added in v0.1.5

func (r RootModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (RootModel) View added in v0.1.5

func (r RootModel) View() string

type TemplatesModel added in v0.1.5

type TemplatesModel struct {
	// contains filtered or unexported fields
}

func NewTemplatesModel added in v0.1.5

func NewTemplatesModel(all []*template.Template) *TemplatesModel

func (*TemplatesModel) Init added in v0.1.5

func (m *TemplatesModel) Init() tea.Cmd

func (*TemplatesModel) Update added in v0.1.5

func (m *TemplatesModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*TemplatesModel) View added in v0.1.5

func (m *TemplatesModel) View() string

func (*TemplatesModel) ViewContent added in v0.1.6

func (m *TemplatesModel) ViewContent() string

ViewContent returns the raw (non-centered) content of this screen. RootModel is responsible for applying any alignment/centering.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL