Documentation
¶
Index ¶
- func EncodeJSON(w io.Writer, data interface{}) error
- func EncodeYAML(w io.Writer, data interface{}) error
- func FormatBulkResult(result *BulkOperationResult, format Format) error
- func FormatOutput(data interface{}, format Format) error
- func IsTTY() bool
- type BulkOperationResult
- type Format
- type KeyValue
- type KeyValueBuilder
- type KeyValueData
- type Renderable
- type ResourceResult
- type TableBuilder
- func (tb *TableBuilder) AddRow(cols ...string) *TableBuilder
- func (tb *TableBuilder) AddSeparator() *TableBuilder
- func (tb *TableBuilder) Format(format Format) error
- func (tb *TableBuilder) WithDynamicColumn(index int) *TableBuilder
- func (tb *TableBuilder) WithMinColumnWidths(widths ...int) *TableBuilder
- func (tb *TableBuilder) WithOptions(opts TableOptions) *TableBuilder
- func (tb *TableBuilder) WithResponsive() *TableBuilder
- func (tb *TableBuilder) WithTerminalWidth(width int) *TableBuilder
- type TableData
- type TableOptions
- type Terminal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeJSON ¶ added in v1.19.0
EncodeJSON encodes data as JSON to the writer
func EncodeYAML ¶ added in v1.19.0
EncodeYAML encodes data as YAML to the writer
func FormatBulkResult ¶
func FormatBulkResult(result *BulkOperationResult, format Format) error
FormatBulkResult formats a BulkOperationResult according to the specified format
func FormatOutput ¶ added in v1.19.0
FormatOutput formats data according to the specified format It handles common data types (TableData, KeyValueData) and falls back to generic encoding for other types
Types ¶
type BulkOperationResult ¶
type BulkOperationResult struct {
Added []ResourceResult `json:"added" yaml:"added"`
Updated []ResourceResult `json:"updated" yaml:"updated"`
Skipped []ResourceResult `json:"skipped" yaml:"skipped"`
Failed []ResourceResult `json:"failed" yaml:"failed"`
CommandCount int `json:"command_count" yaml:"command_count"`
SkillCount int `json:"skill_count" yaml:"skill_count"`
AgentCount int `json:"agent_count" yaml:"agent_count"`
PackageCount int `json:"package_count" yaml:"package_count"`
}
BulkOperationResult represents the result of a bulk repository operation
func FromBulkImportResult ¶
func FromBulkImportResult(result *repo.BulkImportResult) *BulkOperationResult
FromBulkImportResult converts a repo.BulkImportResult to BulkOperationResult
type Format ¶
type Format string
Format represents an output format type
func ParseFormat ¶
ParseFormat parses a format string into a Format type
type KeyValue ¶ added in v1.19.0
type KeyValue struct {
Key string `json:"key" yaml:"key"`
Value string `json:"value" yaml:"value"`
}
KeyValue represents a single key-value pair
type KeyValueBuilder ¶ added in v1.19.0
type KeyValueBuilder struct {
// contains filtered or unexported fields
}
KeyValueBuilder provides a fluent API for building key-value output
func NewKeyValue ¶ added in v1.19.0
func NewKeyValue(title string) *KeyValueBuilder
NewKeyValue creates a new KeyValueBuilder with the given title
func (*KeyValueBuilder) Add ¶ added in v1.19.0
func (kvb *KeyValueBuilder) Add(key, value string) *KeyValueBuilder
Add adds a key-value pair
func (*KeyValueBuilder) AddSection ¶ added in v1.19.0
func (kvb *KeyValueBuilder) AddSection() *KeyValueBuilder
AddSection adds a blank line for visual grouping
func (*KeyValueBuilder) Format ¶ added in v1.19.0
func (kvb *KeyValueBuilder) Format(format Format) error
Format outputs the key-value data in the specified format
type KeyValueData ¶ added in v1.19.0
type KeyValueData struct {
Title string `json:"title,omitempty" yaml:"title,omitempty"`
Pairs []KeyValue `json:"pairs" yaml:"pairs"`
}
KeyValueData represents key-value pair output
type Renderable ¶ added in v1.19.0
Renderable interface for custom complex layouts
type ResourceResult ¶
type ResourceResult struct {
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Message string `json:"message,omitempty" yaml:"message,omitempty"`
Path string `json:"path,omitempty" yaml:"path,omitempty"`
}
ResourceResult represents the result of a single resource operation
type TableBuilder ¶ added in v1.19.0
type TableBuilder struct {
// contains filtered or unexported fields
}
TableBuilder provides a fluent API for building tables
func NewTable ¶ added in v1.19.0
func NewTable(headers ...string) *TableBuilder
NewTable creates a new TableBuilder with the given headers
func (*TableBuilder) AddRow ¶ added in v1.19.0
func (tb *TableBuilder) AddRow(cols ...string) *TableBuilder
AddRow adds a row to the table
func (*TableBuilder) AddSeparator ¶ added in v1.19.0
func (tb *TableBuilder) AddSeparator() *TableBuilder
AddSeparator adds an empty row for visual grouping
func (*TableBuilder) Format ¶ added in v1.19.0
func (tb *TableBuilder) Format(format Format) error
Format outputs the table in the specified format
func (*TableBuilder) WithDynamicColumn ¶ added in v1.22.0
func (tb *TableBuilder) WithDynamicColumn(index int) *TableBuilder
WithDynamicColumn marks a specific column index to stretch and fill remaining space. Pass -1 to use the rightmost visible column (default behavior). The dynamic column will expand to use all remaining terminal width after allocating minimum widths to other columns.
Example:
table := NewTable("Name", "Description", "Status").
WithResponsive().
WithDynamicColumn(1) // Description column fills remaining space
func (*TableBuilder) WithMinColumnWidths ¶ added in v1.22.0
func (tb *TableBuilder) WithMinColumnWidths(widths ...int) *TableBuilder
WithMinColumnWidths sets minimum widths for each column. Columns will never shrink below these widths (except when hidden entirely). Pass fewer widths than columns to only constrain the first N columns.
Example:
table := NewTable("Name", "Description", "Status").
WithResponsive().
WithMinColumnWidths(10, 15, 8) // Name: 10, Description: 15, Status: 8
func (*TableBuilder) WithOptions ¶ added in v1.19.0
func (tb *TableBuilder) WithOptions(opts TableOptions) *TableBuilder
WithOptions sets custom table options
func (*TableBuilder) WithResponsive ¶ added in v1.21.0
func (tb *TableBuilder) WithResponsive() *TableBuilder
WithResponsive enables terminal-aware column sizing
func (*TableBuilder) WithTerminalWidth ¶ added in v1.22.0
func (tb *TableBuilder) WithTerminalWidth(width int) *TableBuilder
WithTerminalWidth sets an explicit terminal width (mainly for testing) Pass 0 to use auto-detection (default behavior)
type TableData ¶ added in v1.19.0
type TableData struct {
Headers []string `json:"headers" yaml:"headers"`
Rows [][]string `json:"rows" yaml:"rows"`
Options TableOptions `json:"-" yaml:"-"`
}
TableData represents structured table data
type TableOptions ¶ added in v1.19.0
type TableOptions struct {
ShowBorders bool
AutoWrap bool
Responsive bool // Enable terminal-aware sizing
TerminalWidth int // Explicit terminal width (0 = auto-detect)
DynamicColumn int // Index of column to stretch (-1 = rightmost visible)
MinColumnWidths []int // Minimum width for each column (0 = use default)
MinTerminalWidth int // Minimum terminal width for responsive mode (default: 15)
}
TableOptions configures table rendering behavior
type Terminal ¶ added in v1.21.0
type Terminal struct {
// contains filtered or unexported fields
}
Terminal provides terminal size information
func NewTerminal ¶ added in v1.21.0
NewTerminal creates a new Terminal with current dimensions