Documentation
¶
Index ¶
- func DiagnosticLevelName(level DiagnosticLevel) string
- func FormatMappingNode(node *core.MappingNode) string
- func FormatMappingNodeWithOptions(node *core.MappingNode, opts FormatMappingNodeOptions) string
- func FormatScalarValue(scalar *core.ScalarValue) string
- func IsHeadless() bool
- func SetHeadlessForTesting(headless bool) func()
- func Validate(requirements ...Requirement) error
- type Condition
- type DiagnosticLevel
- type Flag
- type FormatMappingNodeOptions
- type PrefixedWriter
- func (pw *PrefixedWriter) DoubleSeparator(width int)
- func (pw *PrefixedWriter) Prefix() string
- func (pw *PrefixedWriter) Printf(format string, args ...any)
- func (pw *PrefixedWriter) Println(s string)
- func (pw *PrefixedWriter) PrintlnEmpty()
- func (pw *PrefixedWriter) Separator(char rune, width int)
- func (pw *PrefixedWriter) SingleSeparator(width int)
- func (pw *PrefixedWriter) Writer() io.Writer
- type Printer
- func (p *Printer) CountSummary(count int, singular, plural, verb string)
- func (p *Printer) Diagnostic(level string, message string, line, col int)
- func (p *Printer) FieldAdd(path, value string)
- func (p *Printer) FieldModify(path, oldValue, newValue string)
- func (p *Printer) FieldRemove(path string)
- func (p *Printer) ItemHeader(itemType, name, action string)
- func (p *Printer) NextStep(description, command string)
- func (p *Printer) NoChanges()
- func (p *Printer) ProgressItem(icon, itemType, name, action, suffix string)
- func (p *Printer) Width() int
- func (p *Printer) Writer() *PrefixedWriter
- type Requirement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiagnosticLevelName ¶ added in v0.1.2
func DiagnosticLevelName(level DiagnosticLevel) string
DiagnosticLevelName returns the display name for a diagnostic level.
func FormatMappingNode ¶ added in v0.1.2
func FormatMappingNode(node *core.MappingNode) string
FormatMappingNode formats a MappingNode for display.
func FormatMappingNodeWithOptions ¶ added in v0.1.3
func FormatMappingNodeWithOptions(node *core.MappingNode, opts FormatMappingNodeOptions) string
FormatMappingNodeWithOptions formats a MappingNode for display with configurable options.
func FormatScalarValue ¶ added in v0.1.2
func FormatScalarValue(scalar *core.ScalarValue) string
FormatScalarValue formats a ScalarValue for display.
func IsHeadless ¶
func IsHeadless() bool
IsHeadless returns true if not running in an interactive terminal
func SetHeadlessForTesting ¶
func SetHeadlessForTesting(headless bool) func()
SetHeadlessForTesting overrides IsHeadless for testing purposes. Returns a cleanup function that restores the original behavior.
func Validate ¶
func Validate(requirements ...Requirement) error
Validate checks all requirements, but only if in headless mode. In interactive mode, returns nil (TUI will handle missing values).
Types ¶
type Condition ¶ added in v0.1.3
Condition represents a predicate that can be evaluated
func BoolFlagTrue ¶ added in v0.1.3
BoolFlagTrue returns a condition that is true when the bool flag is set to true
func FlagEquals ¶ added in v0.1.3
FlagEquals returns a condition that is true when the flag has the specified value
func FlagPresent ¶ added in v0.1.3
FlagPresent returns a condition that is true when the flag is explicitly set
type DiagnosticLevel ¶ added in v0.1.2
type DiagnosticLevel int
DiagnosticLevel represents the level of a diagnostic.
const ( DiagnosticLevelError DiagnosticLevel = iota DiagnosticLevelWarning DiagnosticLevelInfo )
func DiagnosticLevelFromCore ¶ added in v0.1.2
func DiagnosticLevelFromCore(level core.DiagnosticLevel) DiagnosticLevel
DiagnosticLevelFromCore converts core.DiagnosticLevel to headless.DiagnosticLevel.
type Flag ¶
type Flag struct {
Name string // Flag name for error messages (e.g., "blueprint-file")
Value string // Current value
IsDefault bool // True if using default value (not explicitly set)
}
Flag represents a flag value with its default status
type FormatMappingNodeOptions ¶ added in v0.1.3
type FormatMappingNodeOptions struct {
// PrettyPrint enables JSON pretty-printing for arrays and maps
// instead of the concise representation ({...}, [...]).
PrettyPrint bool
// Indent specifies the indentation string for pretty-printing.
// Defaults to " " (two spaces) if empty.
Indent string
}
FormatMappingNodeOptions configures how MappingNode values are formatted.
type PrefixedWriter ¶ added in v0.1.2
type PrefixedWriter struct {
// contains filtered or unexported fields
}
PrefixedWriter wraps an io.Writer to auto-prefix all lines.
func NewPrefixedWriter ¶ added in v0.1.2
func NewPrefixedWriter(w io.Writer, prefix string) *PrefixedWriter
NewPrefixedWriter creates a writer that prefixes all output lines.
func (*PrefixedWriter) DoubleSeparator ¶ added in v0.1.2
func (pw *PrefixedWriter) DoubleSeparator(width int)
DoubleSeparator writes a double-line separator (═).
func (*PrefixedWriter) Prefix ¶ added in v0.1.2
func (pw *PrefixedWriter) Prefix() string
Prefix returns the prefix string.
func (*PrefixedWriter) Printf ¶ added in v0.1.2
func (pw *PrefixedWriter) Printf(format string, args ...any)
Printf writes a formatted line with the prefix.
func (*PrefixedWriter) Println ¶ added in v0.1.2
func (pw *PrefixedWriter) Println(s string)
Println writes a line with the prefix.
func (*PrefixedWriter) PrintlnEmpty ¶ added in v0.1.2
func (pw *PrefixedWriter) PrintlnEmpty()
PrintlnEmpty writes an empty line (no prefix).
func (*PrefixedWriter) Separator ¶ added in v0.1.2
func (pw *PrefixedWriter) Separator(char rune, width int)
Separator writes a separator line with the given character.
func (*PrefixedWriter) SingleSeparator ¶ added in v0.1.2
func (pw *PrefixedWriter) SingleSeparator(width int)
SingleSeparator writes a single-line separator (─).
func (*PrefixedWriter) Writer ¶ added in v0.1.2
func (pw *PrefixedWriter) Writer() io.Writer
Writer returns the underlying io.Writer.
type Printer ¶ added in v0.1.2
type Printer struct {
// contains filtered or unexported fields
}
Printer provides common headless output patterns.
func NewPrinter ¶ added in v0.1.2
func NewPrinter(w *PrefixedWriter, width int) *Printer
NewPrinter creates a headless printer.
func (*Printer) CountSummary ¶ added in v0.1.2
CountSummary prints a count with pluralization.
func (*Printer) Diagnostic ¶ added in v0.1.2
Diagnostic prints a diagnostic message with level, location, and wrapped text.
func (*Printer) FieldModify ¶ added in v0.1.2
FieldModify prints a modified field.
func (*Printer) FieldRemove ¶ added in v0.1.2
FieldRemove prints a removed field.
func (*Printer) ItemHeader ¶ added in v0.1.2
ItemHeader prints an item header with type, name, and action. Format: itemType (padded to 10 chars) + space + name + padding + action The action is right-aligned to column 60.
func (*Printer) NoChanges ¶ added in v0.1.2
func (p *Printer) NoChanges()
NoChanges prints a "no changes" message.
func (*Printer) ProgressItem ¶ added in v0.1.2
ProgressItem prints a progress event line. Format: icon type: name - action (suffix)
func (*Printer) Writer ¶ added in v0.1.2
func (p *Printer) Writer() *PrefixedWriter
Writer returns the underlying PrefixedWriter.
type Requirement ¶
type Requirement interface {
Validate() error
}
Requirement defines a validation rule
func OneOf ¶
func OneOf(flags ...Flag) Requirement
OneOf creates a rule that at least one of the flags must be provided
func Required ¶
func Required(f Flag) Requirement
Required creates a rule that the flag must be explicitly provided
func RequiredIf ¶ added in v0.1.3
func RequiredIf(condition Condition, target Flag) Requirement
RequiredIf creates a rule that the target flag is required when the condition is met
func RequiredIfBool ¶ added in v0.1.3
func RequiredIfBool(condition Condition, targetName string, targetValue bool) Requirement
RequiredIfBool creates a rule that the target bool flag must be true when the condition is met