headless

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

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

type Condition interface {
	IsMet() bool
	Description() string
}

Condition represents a predicate that can be evaluated

func BoolFlagTrue added in v0.1.3

func BoolFlagTrue(name string, value bool) Condition

BoolFlagTrue returns a condition that is true when the bool flag is set to true

func FlagEquals added in v0.1.3

func FlagEquals(f Flag, value string) Condition

FlagEquals returns a condition that is true when the flag has the specified value

func FlagPresent added in v0.1.3

func FlagPresent(f Flag) Condition

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

func (p *Printer) CountSummary(count int, singular, plural, verb string)

CountSummary prints a count with pluralization.

func (*Printer) Diagnostic added in v0.1.2

func (p *Printer) Diagnostic(level string, message string, line, col int)

Diagnostic prints a diagnostic message with level, location, and wrapped text.

func (*Printer) FieldAdd added in v0.1.2

func (p *Printer) FieldAdd(path, value string)

FieldAdd prints an added field.

func (*Printer) FieldModify added in v0.1.2

func (p *Printer) FieldModify(path, oldValue, newValue string)

FieldModify prints a modified field.

func (*Printer) FieldRemove added in v0.1.2

func (p *Printer) FieldRemove(path string)

FieldRemove prints a removed field.

func (*Printer) ItemHeader added in v0.1.2

func (p *Printer) ItemHeader(itemType, name, action string)

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) NextStep added in v0.1.2

func (p *Printer) NextStep(description, command string)

NextStep prints a "to do X, run:" instruction.

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

func (p *Printer) ProgressItem(icon, itemType, name, action, suffix string)

ProgressItem prints a progress event line. Format: icon type: name - action (suffix)

func (*Printer) Width added in v0.1.2

func (p *Printer) Width() int

Width returns the configured terminal width.

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

Jump to

Keyboard shortcuts

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