Documentation
¶
Index ¶
- Constants
- Variables
- func BuildStageCount(selection OutputSelection) int
- func DetectDarkBackground() bool
- func DetectDarkBackgroundFromEnv(env []string) bool
- func DetectProfile(output io.Writer, env []string) colorprofile.Profile
- func DetectStdoutProfile() colorprofile.Profile
- func ErrorText(value any) string
- func FormatActivity(update printingpress.ActivityUpdate) string
- func FormatCount[T ~int | ~int64](value T) string
- func FormatRuntimeMetrics(snapshot RuntimeMetricsSnapshot) string
- func FormatStatusLine(label, message string) string
- func FprintBox(writer io.Writer, content string, opts BoxOptions)
- func FprintBulletList(writer io.Writer, items []BulletListItem)
- func HumanBytes(size int64) string
- func HumanRuntimeBytes(size uint64) string
- func LogSuccess(logger *slog.Logger, msg string, args ...any)
- func MutedText(value any) string
- func NewCLIPrettyLogger(writer io.Writer, level slog.Leveler) *slog.Logger
- func NewPrettyLogger(opts *PrettyHandlerOptions) *slog.Logger
- func PrimaryText(value any) string
- func PrintAggregateSummary(writer io.Writer, palette Palette, catalog *ppmodel.CatalogSite, ...)
- func PrintBanner(opts BannerOptions)
- func PrintSummary(writer io.Writer, palette Palette, site *ppmodel.Site, ...)
- func RenderBox(content string, opts BoxOptions) string
- func RenderBulletList(items []BulletListItem) string
- func RenderPanelGrid(rows [][]string, opts PanelOptions) string
- func RoundDuration(d time.Duration) time.Duration
- func RunWithActivity[T any](pp *printingpress.PrintingPress, renderer ActivityRenderer, ...) (T, error)
- func ScanOutputDir(root string) (int, int64, error)
- func SecondaryText(value any) string
- func SuccessText(value any) string
- func WarningText(value any) string
- type ActivityRenderMode
- type ActivityRenderer
- type AggregatePoolRenderer
- type BannerOptions
- type BoxOptions
- type BuildLoggerSession
- type BulletListItem
- type ColorScheme
- type GrayscaleColorScheme
- func (GrayscaleColorScheme) Addition(s string) string
- func (GrayscaleColorScheme) Breaking(s string) string
- func (GrayscaleColorScheme) Detail(s string) string
- func (GrayscaleColorScheme) LocationInfo(s string) string
- func (GrayscaleColorScheme) Modification(s string) string
- func (GrayscaleColorScheme) Removal(s string) string
- func (GrayscaleColorScheme) Statistics(s string) string
- func (GrayscaleColorScheme) TreeBranch(s string) string
- type NoColorScheme
- func (NoColorScheme) Addition(s string) string
- func (NoColorScheme) Breaking(s string) string
- func (NoColorScheme) Detail(s string) string
- func (NoColorScheme) LocationInfo(s string) string
- func (NoColorScheme) Modification(s string) string
- func (NoColorScheme) Removal(s string) string
- func (NoColorScheme) Statistics(s string) string
- func (NoColorScheme) TreeBranch(s string) string
- type OutputSelection
- type Palette
- type PanelOptions
- type PrettyHandler
- func (h *PrettyHandler) Buffered() string
- func (h *PrettyHandler) Enabled(_ context.Context, level slog.Level) bool
- func (h *PrettyHandler) Flush() error
- func (h *PrettyHandler) Handle(_ context.Context, r slog.Record) error
- func (h *PrettyHandler) Reset()
- func (h *PrettyHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *PrettyHandler) WithGroup(name string) slog.Handler
- type PrettyHandlerOptions
- type RuntimeMetricsMonitor
- type RuntimeMetricsSnapshot
- type TerminalColorScheme
- func (TerminalColorScheme) Addition(s string) string
- func (TerminalColorScheme) Breaking(s string) string
- func (TerminalColorScheme) Detail(s string) string
- func (TerminalColorScheme) LocationInfo(s string) string
- func (TerminalColorScheme) Modification(s string) string
- func (TerminalColorScheme) Removal(s string) string
- func (TerminalColorScheme) Statistics(s string) string
- func (TerminalColorScheme) TreeBranch(s string) string
- type TextStyler
- type ThemeName
- type ThemedColorScheme
- func (t ThemedColorScheme) Addition(s string) string
- func (t ThemedColorScheme) Breaking(s string) string
- func (t ThemedColorScheme) Detail(s string) string
- func (t ThemedColorScheme) LocationInfo(s string) string
- func (t ThemedColorScheme) Modification(s string) string
- func (t ThemedColorScheme) Removal(s string) string
- func (t ThemedColorScheme) Statistics(s string) string
- func (t ThemedColorScheme) TreeBranch(s string) string
Constants ¶
const ( // reset clears all formatting Reset = "\033[0m" // green is used for additions (ANSI 256-color code 46) Green = "\033[38;5;46m" // yellow is used for modifications (ANSI 256-color code 220) Yellow = "\033[38;5;220m" // red is used for removals (ANSI 256-color code 196) Red = "\033[38;5;196m" // redBold is used for breaking changes - bold red for emphasis RedBold = "\033[1;38;5;196m" // grey is used for tree structure and location info (ANSI 256-color code 240) Grey = "\033[38;5;240m" )
ANSI escape codes retained for compatibility with existing terminal renderers.
const ( LipglossGreen = "46" LipglossYellow = "220" LipglossRed = "196" LipglossGrey = "240" LipglossLightGrey = "246" // pb33f dark-theme brand colors from cowboy-components. LipglossPrimaryBlue = "#62c4ff" LipglossSecondaryPink = "#f83aff" )
Legacy lipgloss-compatible color constants retained for compatibility.
const ( TimeFormatFull = time.RFC3339 TimeFormatDateTime = "2006-01-02 15:04:05" TimeFormatTimeOnly = "15:04:05" )
TimeFormat constants for common timestamp formats.
const LevelSuccess = slog.Level(2) // between Info (0) and Warn (4)
LevelSuccess is a custom log level for success messages.
Variables ¶
var ActivityRenderWaitTimeout = 2 * time.Second
var DefaultRuntimeMetricsInterval = time.Second
Functions ¶
func BuildStageCount ¶ added in v0.0.68
func BuildStageCount(selection OutputSelection) int
func DetectDarkBackground ¶ added in v0.0.50
func DetectDarkBackground() bool
func DetectDarkBackgroundFromEnv ¶ added in v0.0.55
func DetectProfile ¶ added in v0.0.50
func DetectProfile(output io.Writer, env []string) colorprofile.Profile
func DetectStdoutProfile ¶ added in v0.0.50
func DetectStdoutProfile() colorprofile.Profile
func FormatActivity ¶ added in v0.0.68
func FormatActivity(update printingpress.ActivityUpdate) string
FormatActivity renders a single printing press activity update as plain text.
func FormatCount ¶ added in v0.0.68
func FormatRuntimeMetrics ¶ added in v0.0.68
func FormatRuntimeMetrics(snapshot RuntimeMetricsSnapshot) string
func FormatStatusLine ¶ added in v0.0.68
FormatStatusLine renders a stage/status pair as plain text.
func FprintBox ¶ added in v0.0.62
func FprintBox(writer io.Writer, content string, opts BoxOptions)
FprintBox writes a rendered box to writer, defaulting to stdout.
func FprintBulletList ¶ added in v0.0.62
func FprintBulletList(writer io.Writer, items []BulletListItem)
FprintBulletList writes a rendered bullet list to writer, defaulting to stdout.
func HumanBytes ¶ added in v0.0.68
HumanBytes formats a byte count using binary units.
func HumanRuntimeBytes ¶ added in v0.0.68
func LogSuccess ¶ added in v0.0.62
LogSuccess writes a success-style log record using the PrettyHandler success level.
func NewCLIPrettyLogger ¶ added in v0.0.62
NewCLIPrettyLogger creates a PrettyHandler-backed logger for CLI output.
func NewPrettyLogger ¶ added in v0.0.50
func NewPrettyLogger(opts *PrettyHandlerOptions) *slog.Logger
NewPrettyLogger creates a new slog.Logger with a PrettyHandler.
func PrimaryText ¶ added in v0.0.62
func PrintAggregateSummary ¶ added in v0.0.68
func PrintAggregateSummary(writer io.Writer, palette Palette, catalog *ppmodel.CatalogSite, htmlStats, jsonStats, llmStats *printingpress.AggregatePressStatistics, totalDuration time.Duration, fileCount int, totalBytes int64)
func PrintBanner ¶ added in v0.0.50
func PrintBanner(opts BannerOptions)
PrintBanner renders the shared pb33f banner for a CLI product.
func PrintSummary ¶ added in v0.0.68
func RenderBox ¶ added in v0.0.62
func RenderBox(content string, opts BoxOptions) string
RenderBox renders content inside a deterministic Unicode box.
func RenderBulletList ¶ added in v0.0.62
func RenderBulletList(items []BulletListItem) string
RenderBulletList renders a nested bullet list.
func RenderPanelGrid ¶ added in v0.0.62
func RenderPanelGrid(rows [][]string, opts PanelOptions) string
RenderPanelGrid renders a rectangular grid of pre-rendered panel strings.
func RoundDuration ¶ added in v0.0.68
RoundDuration trims terminal-facing durations to millisecond precision.
func RunWithActivity ¶ added in v0.0.68
func RunWithActivity[T any](pp *printingpress.PrintingPress, renderer ActivityRenderer, run func() (T, error)) (T, error)
RunWithActivity renders a printing press activity stream while run executes.
func ScanOutputDir ¶ added in v0.0.68
ScanOutputDir returns the count and combined size of files below root.
func SecondaryText ¶ added in v0.0.62
func SuccessText ¶ added in v0.0.62
func WarningText ¶ added in v0.0.62
Types ¶
type ActivityRenderMode ¶ added in v0.0.68
type ActivityRenderMode int
ActivityRenderMode controls how printing press activity is presented.
const ( ActivityRenderModePlain ActivityRenderMode = iota ActivityRenderModeProgress ActivityRenderModeDebug )
func SelectActivityRenderMode ¶ added in v0.0.68
func SelectActivityRenderMode(writer io.Writer, debug bool) ActivityRenderMode
type ActivityRenderer ¶ added in v0.0.68
type ActivityRenderer interface {
RenderActivity(sub *printingpress.ActivitySubscription)
UpdateManual(stage, task, status string, percent float64, elapsed time.Duration, err error)
Close()
}
ActivityRenderer renders single-spec printing press progress.
func NewActivityRenderer ¶ added in v0.0.68
func NewActivityRenderer(mode ActivityRenderMode, writer io.Writer, palette Palette, totalStages int, logger *slog.Logger) ActivityRenderer
type AggregatePoolRenderer ¶ added in v0.0.68
type AggregatePoolRenderer interface {
Report(update printingpress.AggregateProgressUpdate)
ReportRuntimeMetrics(snapshot RuntimeMetricsSnapshot)
Close()
}
AggregatePoolRenderer renders aggregate printing press pool progress.
func NewAggregatePoolRenderer ¶ added in v0.0.68
func NewAggregatePoolRenderer(mode ActivityRenderMode, writer io.Writer, palette Palette, logger *slog.Logger) AggregatePoolRenderer
type BannerOptions ¶ added in v0.0.50
type BannerOptions struct {
Writer io.Writer
Palette Palette
ProductName string
ProductURL string
Version string
Date string
}
BannerOptions describes the product metadata to print alongside the shared pb33f banner art.
type BoxOptions ¶ added in v0.0.62
type BoxOptions struct {
Title string
PaddingLeft int
PaddingRight int
PaddingTop int
PaddingBottom int
}
BoxOptions configures a simple terminal box renderer.
type BuildLoggerSession ¶ added in v0.0.68
BuildLoggerSession routes slog output so it does not fight live progress.
func ConfigureBuildLogger ¶ added in v0.0.68
func ConfigureBuildLogger(writer io.Writer, palette Palette, mode ActivityRenderMode) *BuildLoggerSession
func (*BuildLoggerSession) Finish ¶ added in v0.0.68
func (s *BuildLoggerSession) Finish(runErr error)
type BulletListItem ¶ added in v0.0.62
BulletListItem describes one item in a nested bullet list.
type ColorScheme ¶
type ColorScheme interface {
Addition(text string) string
Modification(text string) string
Removal(text string) string
Breaking(text string) string
TreeBranch(text string) string
LocationInfo(text string) string
Statistics(text string) string
Detail(text string) string
}
ColorScheme defines how to colorize different elements of tree output. implementations can provide terminal colors, grayscale dimming, or no colors.
func NewThemeColorScheme ¶ added in v0.0.50
func NewThemeColorScheme(theme ThemeName, profile colorprofile.Profile, darkBackground bool) ColorScheme
type GrayscaleColorScheme ¶
type GrayscaleColorScheme struct{}
GrayscaleColorScheme retains backwards-compatible grayscale output.
func (GrayscaleColorScheme) Addition ¶
func (GrayscaleColorScheme) Addition(s string) string
func (GrayscaleColorScheme) Breaking ¶
func (GrayscaleColorScheme) Breaking(s string) string
func (GrayscaleColorScheme) Detail ¶ added in v0.0.50
func (GrayscaleColorScheme) Detail(s string) string
func (GrayscaleColorScheme) LocationInfo ¶
func (GrayscaleColorScheme) LocationInfo(s string) string
func (GrayscaleColorScheme) Modification ¶
func (GrayscaleColorScheme) Modification(s string) string
func (GrayscaleColorScheme) Removal ¶
func (GrayscaleColorScheme) Removal(s string) string
func (GrayscaleColorScheme) Statistics ¶
func (GrayscaleColorScheme) Statistics(s string) string
func (GrayscaleColorScheme) TreeBranch ¶
func (GrayscaleColorScheme) TreeBranch(s string) string
type NoColorScheme ¶
type NoColorScheme struct{}
func (NoColorScheme) Addition ¶
func (NoColorScheme) Addition(s string) string
func (NoColorScheme) Breaking ¶
func (NoColorScheme) Breaking(s string) string
func (NoColorScheme) Detail ¶ added in v0.0.50
func (NoColorScheme) Detail(s string) string
func (NoColorScheme) LocationInfo ¶
func (NoColorScheme) LocationInfo(s string) string
func (NoColorScheme) Modification ¶
func (NoColorScheme) Modification(s string) string
func (NoColorScheme) Removal ¶
func (NoColorScheme) Removal(s string) string
func (NoColorScheme) Statistics ¶
func (NoColorScheme) Statistics(s string) string
func (NoColorScheme) TreeBranch ¶
func (NoColorScheme) TreeBranch(s string) string
type OutputSelection ¶ added in v0.0.68
OutputSelection describes which output stages a build will run.
type Palette ¶ added in v0.0.50
type Palette struct {
Theme ThemeName
Profile colorprofile.Profile
DarkBackground bool
SupportsColor bool
Primary color.Color
Secondary color.Color
Addition color.Color
Modification color.Color
Removal color.Color
Breaking color.Color
Muted color.Color
Detail color.Color
HelpKey color.Color
PrimaryBG color.Color
SecondaryBG color.Color
SubtleBG color.Color
SelectedBG color.Color
RangeBG color.Color
AddedBG color.Color
AddedRangeBG color.Color
RemovedBG color.Color
RemovedRangeBG color.Color
}
func PaletteFor ¶ added in v0.0.50
func PaletteForPrintingPressArgs ¶ added in v0.0.68
func PaletteForProfile ¶ added in v0.0.50
func PaletteForProfile(theme ThemeName, profile colorprofile.Profile, darkBackground bool) Palette
func PaletteForTheme ¶ added in v0.0.50
type PanelOptions ¶ added in v0.0.62
type PanelOptions struct {
Gap int
}
PanelOptions configures panel grid rendering.
type PrettyHandler ¶ added in v0.0.50
type PrettyHandler struct {
// contains filtered or unexported fields
}
PrettyHandler is a slog.Handler that outputs logs in a tree format with colors derived from the terminal Palette.
func NewPrettyHandler ¶ added in v0.0.50
func NewPrettyHandler(opts *PrettyHandlerOptions) *PrettyHandler
NewPrettyHandler creates a new PrettyHandler with the given options.
func (*PrettyHandler) Buffered ¶ added in v0.0.50
func (h *PrettyHandler) Buffered() string
Buffered returns the currently buffered pretty log output.
func (*PrettyHandler) Enabled ¶ added in v0.0.50
Enabled reports whether the handler handles records at the given level.
func (*PrettyHandler) Flush ¶ added in v0.0.50
func (h *PrettyHandler) Flush() error
Flush writes any buffered pretty log output to the configured writer.
func (*PrettyHandler) Reset ¶ added in v0.0.50
func (h *PrettyHandler) Reset()
Reset clears any buffered pretty log output.
type PrettyHandlerOptions ¶ added in v0.0.50
type PrettyHandlerOptions struct {
// Level is the minimum level to log. Defaults to slog.LevelInfo.
Level slog.Leveler
// TimeFormat is the format for timestamps. Defaults to TimeFormatFull (RFC3339).
TimeFormat string
// Writer is the output destination. Defaults to os.Stdout.
Writer io.Writer
// Palette provides colors for styling. Defaults to PaletteForTheme(ThemeDark).
Palette *Palette
// Buffer defers writes until Flush is called.
Buffer bool
}
PrettyHandlerOptions configures the PrettyHandler.
type RuntimeMetricsMonitor ¶ added in v0.0.68
type RuntimeMetricsMonitor struct {
// contains filtered or unexported fields
}
func StartRuntimeMetricsMonitor ¶ added in v0.0.68
func StartRuntimeMetricsMonitor(start time.Time, interval time.Duration, report func(RuntimeMetricsSnapshot)) *RuntimeMetricsMonitor
func (*RuntimeMetricsMonitor) Close ¶ added in v0.0.68
func (m *RuntimeMetricsMonitor) Close()
type RuntimeMetricsSnapshot ¶ added in v0.0.68
type RuntimeMetricsSnapshot struct {
Elapsed time.Duration
HeapAlloc uint64
TotalAlloc uint64
Sys uint64
NumGC uint32
Goroutines int
}
func CaptureRuntimeMetrics ¶ added in v0.0.68
func CaptureRuntimeMetrics(start time.Time) RuntimeMetricsSnapshot
type TerminalColorScheme ¶
type TerminalColorScheme struct{}
TerminalColorScheme retains backwards-compatible full semantic ANSI output.
func (TerminalColorScheme) Addition ¶
func (TerminalColorScheme) Addition(s string) string
func (TerminalColorScheme) Breaking ¶
func (TerminalColorScheme) Breaking(s string) string
func (TerminalColorScheme) Detail ¶ added in v0.0.50
func (TerminalColorScheme) Detail(s string) string
func (TerminalColorScheme) LocationInfo ¶
func (TerminalColorScheme) LocationInfo(s string) string
func (TerminalColorScheme) Modification ¶
func (TerminalColorScheme) Modification(s string) string
func (TerminalColorScheme) Removal ¶
func (TerminalColorScheme) Removal(s string) string
func (TerminalColorScheme) Statistics ¶
func (TerminalColorScheme) Statistics(s string) string
func (TerminalColorScheme) TreeBranch ¶
func (TerminalColorScheme) TreeBranch(s string) string
type TextStyler ¶ added in v0.0.62
type TextStyler struct {
// contains filtered or unexported fields
}
TextStyler applies semantic terminal styles derived from a Palette.
func DefaultTextStyler ¶ added in v0.0.62
func DefaultTextStyler() TextStyler
DefaultTextStyler returns styles for the default dark terminal theme.
func NewTextStyler ¶ added in v0.0.62
func NewTextStyler(p Palette) TextStyler
NewTextStyler creates semantic text styles for a terminal palette.
func (TextStyler) Error ¶ added in v0.0.62
func (t TextStyler) Error(value any) string
func (TextStyler) Muted ¶ added in v0.0.62
func (t TextStyler) Muted(value any) string
func (TextStyler) Primary ¶ added in v0.0.62
func (t TextStyler) Primary(value any) string
func (TextStyler) Secondary ¶ added in v0.0.62
func (t TextStyler) Secondary(value any) string
func (TextStyler) Success ¶ added in v0.0.62
func (t TextStyler) Success(value any) string
func (TextStyler) Warning ¶ added in v0.0.62
func (t TextStyler) Warning(value any) string
type ThemeName ¶ added in v0.0.50
type ThemeName string
func NormalizeThemeName ¶ added in v0.0.50
func ParsePrintingPressTheme ¶ added in v0.0.68
type ThemedColorScheme ¶ added in v0.0.50
type ThemedColorScheme struct {
// contains filtered or unexported fields
}
func (ThemedColorScheme) Addition ¶ added in v0.0.50
func (t ThemedColorScheme) Addition(s string) string
func (ThemedColorScheme) Breaking ¶ added in v0.0.50
func (t ThemedColorScheme) Breaking(s string) string
func (ThemedColorScheme) Detail ¶ added in v0.0.50
func (t ThemedColorScheme) Detail(s string) string
func (ThemedColorScheme) LocationInfo ¶ added in v0.0.50
func (t ThemedColorScheme) LocationInfo(s string) string
func (ThemedColorScheme) Modification ¶ added in v0.0.50
func (t ThemedColorScheme) Modification(s string) string
func (ThemedColorScheme) Removal ¶ added in v0.0.50
func (t ThemedColorScheme) Removal(s string) string
func (ThemedColorScheme) Statistics ¶ added in v0.0.50
func (t ThemedColorScheme) Statistics(s string) string
func (ThemedColorScheme) TreeBranch ¶ added in v0.0.50
func (t ThemedColorScheme) TreeBranch(s string) string