headless

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: Apache-2.0 Imports: 7 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 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 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 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.

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

Jump to

Keyboard shortcuts

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