Documentation
¶
Index ¶
- func BuildForm(fields []FieldDef, prefilled map[string]any) (*huh.Form, map[string]any)
- func DetectImageProtocol() string
- func FetchAndCacheLogo(url, cachePath string) ([]byte, error)
- func FetchAndCacheLogoWithContext(ctx context.Context, url, cachePath string) ([]byte, error)
- func FinalizeResults(results map[string]any) map[string]any
- func IsSimpleSchema(fields []FieldDef) bool
- func LogoCachePath(configDir, name string) string
- func NormalizeForm(fields []FieldDef, original, results map[string]any) (map[string]any, error)
- func RedactInput(schema map[string]any, input map[string]any) map[string]any
- func RenderLogo(w io.Writer, data []byte)
- func ValidateInput(schema map[string]any, input map[string]any) (map[string]any, error)
- type FieldDef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildForm ¶
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 ¶
FetchAndCacheLogo downloads the logo from url and caches it to disk. Returns the image bytes, or cached bytes if already present.
func FetchAndCacheLogoWithContext ¶
FetchAndCacheLogoWithContext bounds downloads to the caller's request context.
func FinalizeResults ¶
FinalizeResults copies pointer values back into the results map and removes internal pointer keys.
func IsSimpleSchema ¶
IsSimpleSchema returns true if the fields are simple enough for a single form.
func LogoCachePath ¶
LogoCachePath returns the path where the logo is cached on disk.
func NormalizeForm ¶
NormalizeForm converts textual bindings back to their schema types and keeps untouched optional values absent. Existing explicit zero values are preserved.
func RenderLogo ¶
RenderLogo writes the logo to w using the appropriate terminal protocol. Does nothing if the terminal doesn't support inline images.
func ValidateInput ¶
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 ¶
SchemaFields extracts field definitions from a JSON schema.