tui

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildForm

func BuildForm(fields []FieldDef, prefilled map[string]any) (*huh.Form, map[string]any)

BuildForm creates a huh.Form from field definitions and pre-filled values. Returns the form and a map that will be populated with results.

func DetectImageProtocol

func DetectImageProtocol() string

DetectImageProtocol returns "iterm2", "kitty", or "" based on terminal env vars.

func FetchAndCacheLogo(url, cachePath string) ([]byte, error)

FetchAndCacheLogo downloads the logo from url and caches it to disk. Returns the image bytes, or cached bytes if already present.

func FetchAndCacheLogoWithContext

func FetchAndCacheLogoWithContext(ctx context.Context, url, cachePath string) ([]byte, error)

FetchAndCacheLogoWithContext bounds downloads to the caller's request context.

func FinalizeResults

func FinalizeResults(results map[string]any) map[string]any

FinalizeResults copies pointer values back into the results map and removes internal pointer keys.

func IsSimpleSchema

func IsSimpleSchema(fields []FieldDef) bool

IsSimpleSchema returns true if the fields are simple enough for a single form.

func LogoCachePath

func LogoCachePath(configDir, name string) string

LogoCachePath returns the path where the logo is cached on disk.

func NormalizeForm

func NormalizeForm(fields []FieldDef, original, results map[string]any) (map[string]any, error)

NormalizeForm converts textual bindings back to their schema types and keeps untouched optional values absent. Existing explicit zero values are preserved.

func RedactInput

func RedactInput(schema map[string]any, input map[string]any) map[string]any
func RenderLogo(w io.Writer, data []byte)

RenderLogo writes the logo to w using the appropriate terminal protocol. Does nothing if the terminal doesn't support inline images.

func ValidateInput

func ValidateInput(schema map[string]any, input map[string]any) (map[string]any, error)

ValidateInput applies schema defaults and validates supported inline JSON Schema constraints identically for flags, files, and forms. The server remains the authority for reference schemas and constraints not supported here.

Types

type FieldDef

type FieldDef struct {
	Name        string
	Type        string
	Description string
	Required    bool
	Enum        []string
	Format      string
	Default     any
	Example     string
	EnumValues  []any
	Schema      map[string]any
}

FieldDef represents a single field extracted from a JSON schema.

func SchemaFields

func SchemaFields(schema map[string]any) []FieldDef

SchemaFields extracts field definitions from a JSON schema.

Jump to

Keyboard shortcuts

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