Documentation
¶
Overview ¶
Package cmdutil provides common utilities for CLI commands
Index ¶
- Constants
- func AddOutputFlag(cmd *cobra.Command, format *string)
- func NewOutput(format string) *tui.Output
- func Render(out *tui.Output, r Renderable) error
- type ActionData
- type CompositeData
- type DetailData
- type ListData
- type MessageData
- type ProgressData
- type Renderable
- type StatusData
- type StatusItem
- type TableData
Constants ¶
const OutputFlag = "output"
OutputFlag is the standard output format flag name
Variables ¶
This section is empty.
Functions ¶
func AddOutputFlag ¶
AddOutputFlag adds the standard --output/-o flag to a command
Types ¶
type ActionData ¶
ActionData represents the result of an action (create, update, delete, etc.)
func (*ActionData) RenderJSON ¶
func (a *ActionData) RenderJSON() any
func (*ActionData) RenderTUI ¶
func (a *ActionData) RenderTUI(out *tui.Output)
type CompositeData ¶
type CompositeData struct {
JSON any // JSON representation
Parts []Renderable // TUI parts rendered in order
}
CompositeData allows combining multiple renderables
func (*CompositeData) RenderJSON ¶
func (c *CompositeData) RenderJSON() any
func (*CompositeData) RenderTUI ¶
func (c *CompositeData) RenderTUI(out *tui.Output)
type DetailData ¶
type DetailData[T any] struct { Title string Item T ItemFunc func(item T, out *tui.Output) // Custom TUI rendering }
DetailData represents detailed information about a single item
func (*DetailData[T]) RenderJSON ¶
func (d *DetailData[T]) RenderJSON() any
func (*DetailData[T]) RenderTUI ¶
func (d *DetailData[T]) RenderTUI(out *tui.Output)
type ListData ¶
type ListData[T any] struct { Items []T Headers []string RowFunc func(item T, styles *tui.Styles) []string // Convert item to row Empty string }
ListData represents a list of items with table rendering
func (*ListData[T]) RenderJSON ¶
type MessageData ¶
type MessageData struct {
Type string // "success", "error", "info", "warning"
Message string
JSON any // Optional custom JSON
}
MessageData represents a simple message (success, error, info, warning)
func (*MessageData) RenderJSON ¶
func (m *MessageData) RenderJSON() any
func (*MessageData) RenderTUI ¶
func (m *MessageData) RenderTUI(out *tui.Output)
type ProgressData ¶
type ProgressData struct {
Operation string
Target string
Progress float64
Total int64
Current int64
}
ProgressData represents progress information (for operations like download)
func (*ProgressData) RenderJSON ¶
func (p *ProgressData) RenderJSON() any
func (*ProgressData) RenderTUI ¶
func (p *ProgressData) RenderTUI(out *tui.Output)
type Renderable ¶
type Renderable interface {
// RenderJSON returns the data structure for JSON output
RenderJSON() any
// RenderTUI renders the TUI output using the provided Output
RenderTUI(out *tui.Output)
}
Renderable is an interface for types that can render themselves in both JSON and TUI formats
type StatusData ¶
type StatusData struct {
Title string
Items []StatusItem
JSON any // Custom JSON representation (optional)
}
StatusData represents key-value status information
func (*StatusData) RenderJSON ¶
func (s *StatusData) RenderJSON() any
func (*StatusData) RenderTUI ¶
func (s *StatusData) RenderTUI(out *tui.Output)
type StatusItem ¶
StatusItem represents a single status key-value pair
type TableData ¶
TableData represents data that can be rendered as a table