Documentation
¶
Index ¶
- func Accent(term *Terminal, text string) string
- func Bar(term *Terminal, filled, total, width int) string
- func Bold(term *Terminal, text string) string
- func BulletList(term *Terminal, items []string) string
- func CheckMark(term *Terminal) string
- func CountHeader(term *Terminal, count int, noun string) string
- func CrossMark(term *Terminal) string
- func Divider(term *Terminal) string
- func ErrorStyle(term *Terminal, text string) string
- func FormatDuration(seconds int) string
- func FormatFloat(f float64, decimals int) string
- func FormatNumber(n int) string
- func Header(term *Terminal, text string) string
- func KeyValue(term *Terminal, pairs []KVPair) string
- func KeyValueCompact(term *Terminal, pairs []KVPair) string
- func Label(term *Terminal, text string) string
- func Max(a, b int) int
- func Min(a, b int) int
- func Muted(term *Terminal, text string) string
- func NumberedList(term *Terminal, items []string) string
- func PadLeft(s string, width int) string
- func PadRight(s string, width int) string
- func Paginator(term *Terminal, total, limit, offset int, hasMore bool) string
- func Percentage(n, total int) string
- func RelativeTime(unixSec int64) string
- func RenderAdvisories(data any, ctx *Context) string
- func RenderAffected(data any, ctx *Context) string
- func RenderCloudLocators(data any, ctx *Context) string
- func RenderCweGuidance(data any, ctx *Context) string
- func RenderEcosystems(ecosystems []any, ctx *Context) string
- func RenderExploitSearch(data any, ctx *Context) string
- func RenderExploits(data any, ctx *Context) string
- func RenderFixes(data any, ctx *Context) string
- func RenderGenericMap(data any, ctx *Context) string
- func RenderIdentifiers(data any, ctx *Context, title string) string
- func RenderKev(data any, ctx *Context) string
- func RenderPackageVulns(data any, ctx *Context) string
- func RenderPackagesSearch(data any, ctx *Context) string
- func RenderProductVersions(data any, ctx *Context) string
- func RenderRemediationPlan(data any, ctx *Context) string
- func RenderScorecard(data any, ctx *Context) string
- func RenderScorecardSearch(data any, ctx *Context) string
- func RenderSimpleList(data any, ctx *Context, noun string) string
- func RenderStatus(data any, ctx *Context) string
- func RenderSummary(data any, ctx *Context) string
- func RenderTimeline(data any, ctx *Context) string
- func RenderTrafficFilters(data any, ctx *Context) string
- func RenderVersions(data any, ctx *Context) string
- func RenderVulnDetail(data any, ctx *Context) string
- func RenderWorkarounds(data any, ctx *Context) string
- func RoundFloat(f float64, n int) float64
- func SeverityBadge(term *Terminal, level string) string
- func SeverityText(term *Terminal, level string) string
- func ShortDivider(term *Terminal, width int) string
- func Subheader(term *Terminal, text string) string
- func Success(term *Terminal, text string) string
- func Table(term *Terminal, cols []Column, rows [][]string) string
- func Teal(term *Terminal, text string) string
- func ToFloat64(v any) float64
- func ToIntVal(v any) int
- func ToMap(v any) map[string]any
- func ToStringVal(v any) string
- func Truncate(s string, max int) string
- func WarningMark(term *Terminal) string
- type Alignment
- type Column
- type Context
- type KVPair
- type Logger
- func (l *Logger) Error(msg string)
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Info(msg string)
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) Result(s string)
- func (l *Logger) ResultJSON(data interface{}) error
- func (l *Logger) Status(msg string)
- func (l *Logger) Statusf(format string, args ...interface{})
- func (l *Logger) Warn(msg string)
- func (l *Logger) Warnf(format string, args ...interface{})
- type OutputMode
- type Progress
- type Terminal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BulletList ¶
BulletList renders a bullet-point list.
func CountHeader ¶
CountHeader renders a "Found N items" header with an optional qualifier.
func FormatDuration ¶
FormatDuration converts seconds into a human-readable duration string.
func FormatFloat ¶
FormatFloat formats a float with specified decimal places.
func FormatNumber ¶
FormatNumber adds comma separators to an integer (e.g., 1234567 → "1,234,567").
func KeyValue ¶
KeyValue renders aligned key-value pairs. An empty Key creates a blank separator line between groups.
func KeyValueCompact ¶
KeyValueCompact renders key-value pairs with minimal spacing.
func NumberedList ¶
NumberedList renders a numbered list (1-indexed).
func Percentage ¶
Percentage formats a ratio as percentage string.
func RelativeTime ¶
RelativeTime formats a Unix timestamp as relative time (e.g., "3 days ago").
func RenderAdvisories ¶
RenderAdvisories renders advisory data.
func RenderAffected ¶
RenderAffected renders affected products/packages.
func RenderCloudLocators ¶
RenderCloudLocators renders cloud resource locator templates.
func RenderCweGuidance ¶
RenderCweGuidance renders CWE-based guidance.
func RenderEcosystems ¶
RenderEcosystems renders the ecosystems list.
func RenderExploitSearch ¶
RenderExploitSearch renders exploit search results.
func RenderExploits ¶
RenderExploits renders exploit data for a vulnerability. Handles both: exploits[] array present (pro) and summary-only (community).
func RenderFixes ¶
RenderFixes renders fix data for a vulnerability.
func RenderGenericMap ¶
RenderGenericMap renders any map data with intelligent formatting. Used as fallback for commands without specific renderers.
func RenderIdentifiers ¶
RenderIdentifiers renders a list of CVE identifiers.
func RenderPackageVulns ¶
RenderPackageVulns renders package vulnerability list.
func RenderPackagesSearch ¶
RenderPackagesSearch renders package search results with vuln/version counts.
func RenderProductVersions ¶
RenderProductVersions renders product version list.
func RenderRemediationPlan ¶
RenderRemediationPlan renders a remediation plan.
func RenderScorecard ¶
RenderScorecard renders a vulnerability scorecard.
func RenderScorecardSearch ¶
RenderScorecardSearch renders scorecard search results.
func RenderSimpleList ¶
RenderSimpleList renders a generic list of items from a map response. Looks for common patterns: items[], results[], data[], or the top-level array. RenderSimpleList renders a generic list with name/count from common list keys.
func RenderStatus ¶
RenderStatus renders VDB status/health information.
func RenderSummary ¶
RenderSummary renders the VDB database summary.
func RenderTimeline ¶
RenderTimeline renders vulnerability timeline events.
func RenderTrafficFilters ¶
RenderTrafficFilters renders IDS/IPS traffic filter rules (Snort).
func RenderVersions ¶
RenderVersions renders package version list.
func RenderVulnDetail ¶
RenderVulnDetail renders a single vulnerability detail view. Handles both flat vuln objects and CVE 5.0 JSON format (array of records with containers/cveMetadata).
func RenderWorkarounds ¶
RenderWorkarounds renders workaround information.
func RoundFloat ¶
RoundFloat rounds a float to n decimal places.
func SeverityBadge ¶
SeverityBadge renders an inline colored severity label.
func SeverityText ¶
SeverityText renders severity text with the appropriate color (no background).
func ShortDivider ¶
ShortDivider renders a shorter divider for subsections.
func Table ¶
Table renders a responsive table without borders. Uses spacing and alignment for visual separation, with bold headers and a thin separator.
func ToMap ¶
ToMap converts a typed struct to map[string]any via JSON round-trip. Useful when renderers expect map data but commands have typed structs.
func ToStringVal ¶
ToStringVal extracts a string from an interface value.
func WarningMark ¶
WarningMark renders a yellow warning indicator.
Types ¶
type Column ¶
type Column struct {
Header string
Width int // 0 = auto-calculate
MinWidth int // minimum width when auto-calculating
MaxWidth int // maximum width when auto-calculating (0 = unlimited)
Align Alignment // left or right alignment
Color func(string) string // optional per-cell coloring function
}
Column defines a table column.
type Context ¶
type Context struct {
Logger *Logger
Term *Terminal
Mode OutputMode
Silent bool
NoProgress bool
}
Context bundles display capabilities for a command.
func FromCommand ¶
FromCommand retrieves the display context from a cobra command. Returns a default text-mode context if none was attached.
func New ¶
func New(mode OutputMode, silent bool) *Context
New creates a display context from mode and silent flag.
func NewFromFlags ¶
NewFromFlags creates a display context from string output flag and silent bool.
func NewWithProgress ¶ added in v3.11.0
func NewWithProgress(mode OutputMode, silent bool, noProgress bool) *Context
NewWithProgress creates a display context from output and progress flags.
type KVPair ¶
type KVPair struct {
Key string
Value string
ValueStyle func(string) string // optional styling for the value
}
KVPair represents a key-value pair for display.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger routes output between stdout and stderr based on mode and silent flags.
func NewLogger ¶
func NewLogger(mode OutputMode, silent bool, term *Terminal) *Logger
NewLogger creates a logger with the given mode and silent flag.
func (*Logger) ResultJSON ¶
ResultJSON encodes data as indented JSON to stdout.
type OutputMode ¶
type OutputMode int
OutputMode determines how output is routed.
const ( ModeText OutputMode = iota ModeJSON )
type Progress ¶ added in v3.11.0
type Progress struct {
// contains filtered or unexported fields
}
Progress renders one transparent activity line on stderr. A progress activity has a static title, a numeric done/total goal, and a stage title that can change while work proceeds inside the current stage.
func (*Progress) Advance ¶ added in v3.11.0
Advance moves progress forward by one unit and updates the stage title.
func (*Progress) Interactive ¶ added in v3.11.0
Interactive reports whether progress is rendering as a live TTY line.
func (*Progress) SetStage ¶ added in v3.11.0
SetStage changes the current stage title without changing numeric progress.
func (*Progress) Update ¶ added in v3.11.0
Update sets the numeric progress and, when non-empty, the current stage.
func (*Progress) Writer ¶ added in v3.13.1
Writer returns a writer that can be used for ordinary log output while this progress activity is active. On interactive terminals it clears the live progress row before writing and redraws it afterwards, so log lines do not leave behind duplicate progress bars.
type Terminal ¶
type Terminal struct {
Width int
Height int
IsTTY bool // stdout is a terminal
StderrTTY bool
ColorProfile termenv.Profile
}
Terminal holds detected terminal capabilities.
func (*Terminal) LipglossRenderer ¶
LipglossRenderer returns a lipgloss renderer configured for this terminal.