Documentation
¶
Overview ¶
Package presenter provides consistent CLI output functionality for user-facing messages, including success, error, warning, and informational output with color support and quiet mode.
Index ¶
- func Error(err error, context string)
- func Info(message string)
- func IsQuiet() bool
- func Prompt(question string, options ...string) string
- func Section(title string)
- func Separator()
- func SetQuiet(quiet bool)
- func Stats(usage *UsageStats)
- func Success(message string)
- func Warning(message string)
- type ColorMode
- type Presenter
- type TerminalPresenter
- func (p *TerminalPresenter) Error(err error, context string)
- func (p *TerminalPresenter) Info(message string)
- func (p *TerminalPresenter) IsQuiet() bool
- func (p *TerminalPresenter) Prompt(question string, options ...string) string
- func (p *TerminalPresenter) Section(title string)
- func (p *TerminalPresenter) Separator()
- func (p *TerminalPresenter) SetQuiet(quiet bool)
- func (p *TerminalPresenter) Stats(usage *UsageStats)
- func (p *TerminalPresenter) Success(message string)
- func (p *TerminalPresenter) Warning(message string)
- type UsageStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Info ¶
func Info(message string)
Info displays an informational message using the default presenter instance.
func IsQuiet ¶
func IsQuiet() bool
IsQuiet returns whether quiet mode is enabled for the default presenter instance.
func Section ¶
func Section(title string)
Section displays a section header using the default presenter instance.
func Separator ¶
func Separator()
Separator displays a visual separator using the default presenter instance.
func SetQuiet ¶
func SetQuiet(quiet bool)
SetQuiet enables or disables quiet mode for the default presenter instance.
func Stats ¶
func Stats(usage *UsageStats)
Stats displays usage statistics using the default presenter instance.
Types ¶
type ColorMode ¶
type ColorMode int
ColorMode represents different color output modes
const ( // ColorAuto automatically detects whether to use colored output based on terminal capabilities ColorAuto ColorMode = iota // ColorAlways forces colored output regardless of terminal capabilities ColorAlways // ColorNever disables colored output regardless of terminal capabilities ColorNever )
type Presenter ¶
type Presenter interface {
Error(err error, context string)
Success(message string)
Warning(message string)
Info(message string)
Section(title string)
Prompt(question string, options ...string) string
Stats(usage *UsageStats)
Separator()
SetQuiet(quiet bool)
IsQuiet() bool
}
Presenter defines the interface for consistent CLI output
type TerminalPresenter ¶
type TerminalPresenter struct {
// contains filtered or unexported fields
}
TerminalPresenter implements Presenter for terminal output
func NewWithOptions ¶
func NewWithOptions(output, errorOutput io.Writer, colorMode ColorMode) *TerminalPresenter
NewWithOptions creates a TerminalPresenter with custom settings
func (*TerminalPresenter) Error ¶
func (p *TerminalPresenter) Error(err error, context string)
Error displays an error message to stderr
func (*TerminalPresenter) Info ¶
func (p *TerminalPresenter) Info(message string)
Info displays an informational message
func (*TerminalPresenter) IsQuiet ¶
func (p *TerminalPresenter) IsQuiet() bool
IsQuiet returns whether quiet mode is enabled
func (*TerminalPresenter) Prompt ¶
func (p *TerminalPresenter) Prompt(question string, options ...string) string
Prompt displays a prompt and reads user input
func (*TerminalPresenter) Section ¶
func (p *TerminalPresenter) Section(title string)
Section displays a section header with consistent formatting
func (*TerminalPresenter) Separator ¶
func (p *TerminalPresenter) Separator()
Separator displays a visual separator
func (*TerminalPresenter) SetQuiet ¶
func (p *TerminalPresenter) SetQuiet(quiet bool)
SetQuiet enables or disables quiet mode
func (*TerminalPresenter) Stats ¶
func (p *TerminalPresenter) Stats(usage *UsageStats)
Stats displays usage statistics in a consistent format
func (*TerminalPresenter) Success ¶
func (p *TerminalPresenter) Success(message string)
Success displays a success message
func (*TerminalPresenter) Warning ¶
func (p *TerminalPresenter) Warning(message string)
Warning displays a warning message
type UsageStats ¶
type UsageStats struct {
InputTokens int64
OutputTokens int64
CacheWriteTokens int64
CacheReadTokens int64
InputCost float64
OutputCost float64
CacheWriteCost float64
CacheReadCost float64
CurrentContextWindow int
MaxContextWindow int
}
UsageStats represents token usage and cost information
func ConvertUsageStats ¶
func ConvertUsageStats(stats *llmtypes.Usage) *UsageStats
ConvertUsageStats converts llmtypes.Usage to presenter.UsageStats