Documentation
¶
Overview ¶
Package output provides output formatting for Sigil CLI.
Index ¶
- func CanRenderQR(w io.Writer) bool
- func FormatError(w io.Writer, err error, format Format) error
- func FormatSuccess(w io.Writer, message string, format Format) error
- func Info(msg string)
- func Infof(format string, args ...any)
- func RenderQR(w io.Writer, data string, cfg QRConfig) error
- func Success(msg string)
- func Successf(format string, args ...any)
- func Warn(msg string)
- func Warnf(format string, args ...any)
- type ErrorDetail
- type ErrorOutput
- type Format
- type Formatter
- type QRConfig
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanRenderQR ¶
CanRenderQR checks if the output writer is a terminal suitable for QR rendering.
func FormatError ¶
FormatError formats an error for display.
func FormatSuccess ¶
FormatSuccess formats a success message.
func Info ¶ added in v1.2.0
func Info(msg string)
Info prints an informational message to stdout with an info prefix.
func RenderQR ¶
RenderQR renders a QR code to the writer if it's a terminal. Returns without error if the writer is not a terminal (no output is produced).
func Success ¶ added in v1.2.0
func Success(msg string)
Success prints a success message to stdout with a success prefix.
Types ¶
type ErrorDetail ¶
type ErrorDetail struct {
Code string `json:"code"`
Message string `json:"message"`
Details map[string]string `json:"details,omitempty"`
Suggestion string `json:"suggestion,omitempty"`
ExitCode int `json:"exit_code"`
}
ErrorDetail contains error details.
type ErrorOutput ¶
type ErrorOutput struct {
Error ErrorDetail `json:"error"`
}
ErrorOutput represents a structured error for JSON output.
type Format ¶
type Format string
Format represents the output format.
Output format constants.
func DetectFormat ¶
DetectFormat determines the appropriate format based on context. Returns JSON for non-TTY output, text for TTY, unless explicitly overridden.
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter handles output formatting.
func NewFormatter ¶
NewFormatter creates a new formatter with the specified format.
type QRConfig ¶
type QRConfig struct {
// Level is the error correction level.
Level qr.Level
// QuietZone is the number of empty blocks around the QR code.
QuietZone int
// HalfBlocks uses half-height blocks for a more compact display.
HalfBlocks bool
}
QRConfig configures QR code rendering.
func DefaultQRConfig ¶
func DefaultQRConfig() QRConfig
DefaultQRConfig returns sensible defaults for terminal QR rendering.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table renders tabular data for text output.
func (*Table) SetNoHeader ¶
SetNoHeader suppresses the header row.
func (*Table) SetSeparator ¶
SetSeparator sets the column separator.