Documentation
¶
Overview ¶
Package output handles CLI output formatting (pretty tables, JSON, raw).
Index ¶
- Variables
- func Errorf(format string, args ...any)
- func Infof(format string, args ...any)
- func InitFormatter(human bool)
- func JSON(data any) error
- func StatusColor(status string) string
- func Successf(format string, args ...any)
- func Table(headers []string, rows [][]string)
- type AgentFormatter
- func (f *AgentFormatter) CheckResult(name, status, message string)
- func (f *AgentFormatter) CheckSummary(ok, warn, fail int)
- func (f *AgentFormatter) Error(msg string)
- func (f *AgentFormatter) Finish()
- func (f *AgentFormatter) Info(msg string)
- func (f *AgentFormatter) KeyValue(key, value string)
- func (f *AgentFormatter) List(items []string)
- func (f *AgentFormatter) Printf(format string, a ...any)
- func (f *AgentFormatter) Println(a ...any)
- func (f *AgentFormatter) Progress(completed, total int)
- func (f *AgentFormatter) Section(title string)
- func (f *AgentFormatter) SectionIcon(_ string) string
- func (f *AgentFormatter) StatusText(status string) string
- func (f *AgentFormatter) Success(msg string)
- func (f *AgentFormatter) Table(headers []string, rows [][]string)
- func (f *AgentFormatter) Warning(msg string)
- type Formatter
- type HumanFormatter
- func (f *HumanFormatter) CheckResult(name, status, message string)
- func (f *HumanFormatter) CheckSummary(ok, warn, fail int)
- func (f *HumanFormatter) Error(msg string)
- func (f *HumanFormatter) Finish()
- func (f *HumanFormatter) Info(msg string)
- func (f *HumanFormatter) KeyValue(key, value string)
- func (f *HumanFormatter) List(items []string)
- func (f *HumanFormatter) Printf(format string, a ...any)
- func (f *HumanFormatter) Println(a ...any)
- func (f *HumanFormatter) Progress(completed, total int)
- func (f *HumanFormatter) Section(title string)
- func (f *HumanFormatter) SectionIcon(id string) string
- func (f *HumanFormatter) StatusText(status string) string
- func (f *HumanFormatter) Success(msg string)
- func (f *HumanFormatter) Table(headers []string, rows [][]string)
- func (f *HumanFormatter) Warning(msg string)
- type Spinner
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // F is the global formatter, set during initialization. F Formatter = &AgentFormatter{w: os.Stdout} // IsHuman indicates whether rich output mode is active. IsHuman bool )
View Source
var ( Bold = color.New(color.Bold).SprintFunc() Green = color.New(color.FgGreen).SprintFunc() Red = color.New(color.FgRed).SprintFunc() Yellow = color.New(color.FgYellow).SprintFunc() Cyan = color.New(color.FgCyan).SprintFunc() Dim = color.New(color.Faint).SprintFunc() Success = color.New(color.FgGreen, color.Bold).SprintFunc() Error = color.New(color.FgRed, color.Bold).SprintFunc() )
Functions ¶
func InitFormatter ¶
func InitFormatter(human bool)
InitFormatter sets up the global formatter based on mode.
func StatusColor ¶
StatusColor returns a colored status string.
Types ¶
type AgentFormatter ¶
type AgentFormatter struct {
// contains filtered or unexported fields
}
func (*AgentFormatter) CheckResult ¶
func (f *AgentFormatter) CheckResult(name, status, message string)
func (*AgentFormatter) CheckSummary ¶
func (f *AgentFormatter) CheckSummary(ok, warn, fail int)
func (*AgentFormatter) Error ¶
func (f *AgentFormatter) Error(msg string)
func (*AgentFormatter) Finish ¶
func (f *AgentFormatter) Finish()
func (*AgentFormatter) Info ¶
func (f *AgentFormatter) Info(msg string)
func (*AgentFormatter) KeyValue ¶
func (f *AgentFormatter) KeyValue(key, value string)
func (*AgentFormatter) List ¶
func (f *AgentFormatter) List(items []string)
func (*AgentFormatter) Printf ¶
func (f *AgentFormatter) Printf(format string, a ...any)
func (*AgentFormatter) Println ¶
func (f *AgentFormatter) Println(a ...any)
func (*AgentFormatter) Progress ¶
func (f *AgentFormatter) Progress(completed, total int)
func (*AgentFormatter) Section ¶
func (f *AgentFormatter) Section(title string)
func (*AgentFormatter) SectionIcon ¶
func (f *AgentFormatter) SectionIcon(_ string) string
func (*AgentFormatter) StatusText ¶
func (f *AgentFormatter) StatusText(status string) string
func (*AgentFormatter) Success ¶
func (f *AgentFormatter) Success(msg string)
func (*AgentFormatter) Table ¶
func (f *AgentFormatter) Table(headers []string, rows [][]string)
func (*AgentFormatter) Warning ¶
func (f *AgentFormatter) Warning(msg string)
type Formatter ¶
type Formatter interface {
Table(headers []string, rows [][]string)
Section(title string)
KeyValue(key, value string)
Success(msg string)
Error(msg string)
Finish()
Info(msg string)
Warning(msg string)
List(items []string)
Progress(completed, total int)
CheckResult(name, status, message string)
CheckSummary(ok, warn, fail int)
StatusText(status string) string
SectionIcon(id string) string
Println(a ...any)
Printf(format string, a ...any)
}
Formatter provides structured output methods for CLI commands.
type HumanFormatter ¶
type HumanFormatter struct {
// contains filtered or unexported fields
}
func (*HumanFormatter) CheckResult ¶
func (f *HumanFormatter) CheckResult(name, status, message string)
func (*HumanFormatter) CheckSummary ¶
func (f *HumanFormatter) CheckSummary(ok, warn, fail int)
func (*HumanFormatter) Error ¶
func (f *HumanFormatter) Error(msg string)
func (*HumanFormatter) Finish ¶
func (f *HumanFormatter) Finish()
Finish prints the agent hint at the end of human-mode output
func (*HumanFormatter) Info ¶
func (f *HumanFormatter) Info(msg string)
func (*HumanFormatter) KeyValue ¶
func (f *HumanFormatter) KeyValue(key, value string)
func (*HumanFormatter) List ¶
func (f *HumanFormatter) List(items []string)
func (*HumanFormatter) Printf ¶
func (f *HumanFormatter) Printf(format string, a ...any)
func (*HumanFormatter) Println ¶
func (f *HumanFormatter) Println(a ...any)
func (*HumanFormatter) Progress ¶
func (f *HumanFormatter) Progress(completed, total int)
func (*HumanFormatter) Section ¶
func (f *HumanFormatter) Section(title string)
func (*HumanFormatter) SectionIcon ¶
func (f *HumanFormatter) SectionIcon(id string) string
func (*HumanFormatter) StatusText ¶
func (f *HumanFormatter) StatusText(status string) string
func (*HumanFormatter) Success ¶
func (f *HumanFormatter) Success(msg string)
func (*HumanFormatter) Table ¶
func (f *HumanFormatter) Table(headers []string, rows [][]string)
func (*HumanFormatter) Warning ¶
func (f *HumanFormatter) Warning(msg string)
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner shows an animated spinner on a single line for human mode. In agent mode it's a no-op.
func NewSpinner ¶
NewSpinner creates and starts a spinner with the given message.
func (*Spinner) StopSuccess ¶
StopSuccess stops with a green checkmark.
func (*Spinner) StopWarning ¶
StopWarning stops with a yellow warning sign.
Click to show internal directories.
Click to hide internal directories.