Documentation
¶
Index ¶
- Constants
- func ColorEnabled() bool
- func ColorHeader(s string) string
- func ColorPercent(pct float64) string
- func CurrencySymbol(vs string) string
- func FormatLargeNumber(n float64, vs ...string) string
- func FormatPercent(pct float64) string
- func FormatPrice(price float64, vs ...string) string
- func FormatRank(rank int) string
- func FormatSupply(n float64) string
- func FormatSymbol(s string) string
- func FprintBanner(w io.Writer)
- func PrintBanner()
- func PrintLogo()
- func PrintTable(headers []string, rows [][]string)
- func PrintWelcomeBox()
- func SanitizeCell(s string) string
- func StderrIsTerminal() bool
- func StdoutColorEnabled() bool
- func StdoutIsTerminal() bool
- func VisibleWidth(s string) int
Constants ¶
const BannerLines = 3
BannerLines is the number of terminal rows FprintBanner occupies (leading \n + text + trailing \n\n). Used by watch to position the status line without hardcoding a row number.
Variables ¶
This section is empty.
Functions ¶
func ColorEnabled ¶ added in v1.0.5
func ColorEnabled() bool
ColorEnabled reports whether color output is allowed (TTY and NO_COLOR not set).
func ColorHeader ¶ added in v1.0.4
ColorHeader wraps s in bold #FFE866 (gold) when color output is enabled.
func ColorPercent ¶
func CurrencySymbol ¶
func FormatLargeNumber ¶
func FormatPercent ¶
func FormatPrice ¶
func FormatRank ¶
FormatRank formats a market cap rank, returning "-" for zero/unranked.
func FormatSupply ¶
func FormatSymbol ¶
FormatSymbol sanitizes and uppercases a coin symbol from API data.
func FprintBanner ¶ added in v1.0.9
FprintBanner writes a compact one-line CoinGecko banner to w. Color is determined by the writer's fd (not the global ColorEnabled check), so writing to stdout vs stderr each gets the right color decision.
func PrintBanner ¶
func PrintBanner()
PrintBanner prints a compact one-line CoinGecko banner to stderr. Writing to stderr keeps stdout clean for piped data.
func PrintLogo ¶
func PrintLogo()
PrintLogo prints the full ASCII art CoinGecko logo in brand green to stderr.
func PrintTable ¶
func PrintWelcomeBox ¶
func PrintWelcomeBox()
PrintWelcomeBox prints a bordered quick-start box to stderr.
func SanitizeCell ¶
SanitizeCell strips all ANSI escape sequences and non-printable control characters from untrusted API data. Call this on API-sourced strings (names, symbols) before passing to PrintTable. Internal color formatting (e.g. ColorPercent) operates on numeric values and should NOT be sanitized.
func StderrIsTerminal ¶ added in v1.0.5
func StderrIsTerminal() bool
StderrIsTerminal reports whether stderr is connected to an interactive terminal.
func StdoutColorEnabled ¶ added in v1.0.9
func StdoutColorEnabled() bool
StdoutColorEnabled reports whether color output is appropriate for stdout. Use this instead of ColorEnabled() when writing colored output to stdout (e.g. the watch table), so colors work even when stderr is redirected.
func StdoutIsTerminal ¶ added in v1.0.9
func StdoutIsTerminal() bool
StdoutIsTerminal reports whether stdout is connected to an interactive terminal.
func VisibleWidth ¶
VisibleWidth returns the display width of a string after stripping ANSI escapes. Uses rune count rather than byte length so multi-byte Unicode (e.g. ▲, ▼, •) is measured as one cell per character.
Types ¶
This section is empty.