tableprinter

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTerminalWidth

func GetTerminalWidth() int

GetTerminalWidth returns the terminal width with fallback

func IsTTY

func IsTTY(w io.Writer) bool

IsTTY detects if the writer is a terminal, following GitHub CLI's logic

func WithColor

func WithColor(colorFunc func(string) string) fieldOption

WithColor applies a color function to a field

func WithPadding

func WithPadding(paddingFunc func(int, string) string) fieldOption

WithPadding applies a custom padding function to a field

func WithTruncate

func WithTruncate(truncateFunc func(int, string) string) fieldOption

WithTruncate applies a custom truncation function to a field

Types

type ColorScheme

type ColorScheme struct {
	// State colors for different entity states
	Green   func(string) string // Active/Open items
	Red     func(string) string // Completed/Closed items
	Magenta func(string) string // Special/Merged items
	Gray    func(string) string // Draft/Inactive items
	Cyan    func(string) string // Names/Identifiers
	Yellow  func(string) string // Private/Warning items
	Muted   func(string) string // Secondary info/timestamps
	Bold    func(string) string // Emphasis
}

ColorScheme provides state-based color functions following GitHub CLI's design

func NewColorScheme

func NewColorScheme() *ColorScheme

NewColorScheme creates a new color scheme with TTY detection

func (*ColorScheme) AccountName

func (cs *ColorScheme) AccountName(s string) string

func (*ColorScheme) ColorFromString

func (cs *ColorScheme) ColorFromString(state string) func(string) string

ColorFromString returns a color function based on a state string This matches GitHub CLI's pattern for dynamic color selection

func (*ColorScheme) Description

func (cs *ColorScheme) Description(s string) string

func (*ColorScheme) ID

func (cs *ColorScheme) ID(s string) string

func (*ColorScheme) ProjectActive

func (cs *ColorScheme) ProjectActive(s string) string

Predefined color functions for common Basecamp entity states

func (*ColorScheme) ProjectArchived

func (cs *ColorScheme) ProjectArchived(s string) string

func (*ColorScheme) Timestamp

func (cs *ColorScheme) Timestamp(s string) string

func (*ColorScheme) TodoCompleted

func (cs *ColorScheme) TodoCompleted(s string) string

func (*ColorScheme) TodoIncomplete

func (cs *ColorScheme) TodoIncomplete(s string) string

func (*ColorScheme) TodoListName

func (cs *ColorScheme) TodoListName(s string) string

type TablePrinter

type TablePrinter interface {
	AddHeader([]string, ...fieldOption)
	AddField(string, ...fieldOption)
	EndRow()
	Render() error
}

TablePrinter provides the interface for table rendering, matching GitHub CLI's design

func New

func New(writer io.Writer, isTTY bool, maxWidth int) TablePrinter

New creates a new TablePrinter based on the writer and TTY detection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL