struct Obsctl::CLI::Palette

Overview

Resolved ANSI palette for human-readable CLI output.

Formatters interpolate these unconditionally; when color is disabled every accessor returns an empty string, so a single code path produces both the decorated terminal form and the plain form used for pipes, files, and golden fixtures.

Defined in:

obsctl/cli/color.cr

Constant Summary

BLUE = "\e[34m"
BOLD = "\e[1m"
BRIGHT_WHITE = "\e[97m"
CYAN = "\e[36m"
DIM = "\e[2m"
GREEN = "\e[32m"
MAGENTA = "\e[35m"
RED = "\e[31m"
RESET = "\e[0m"
YELLOW = "\e[33m"

Constructors

Instance Method Summary

Constructor Detail

def self.colored : self #

Palette that always emits escape sequences.


[View source]
def self.monochrome : self #

Palette that never emits escape sequences.


[View source]
def self.new(enabled : Bool = false) #

[View source]
def self.resolve(mode : ColorMode, io : IO, env = ENV) : self #

Resolves the palette for one invocation.

Auto colors only a real terminal, and defers to NO_COLOR and TERM=dumb so redirected output and dumb terminals stay plain.


[View source]

Instance Method Detail

def blue : String #

Returns the blue escape sequence, or "" when color is disabled.


[View source]
def bold : String #

Returns the bold escape sequence, or "" when color is disabled.


[View source]
def bright_white : String #

Returns the bright_white escape sequence, or "" when color is disabled.


[View source]
def cyan : String #

Returns the cyan escape sequence, or "" when color is disabled.


[View source]
def dim : String #

Returns the dim escape sequence, or "" when color is disabled.


[View source]
def enabled? : Bool #

[View source]
def green : String #

Returns the green escape sequence, or "" when color is disabled.


[View source]
def magenta : String #

Returns the magenta escape sequence, or "" when color is disabled.


[View source]
def red : String #

Returns the red escape sequence, or "" when color is disabled.


[View source]
def reset : String #

Returns the reset escape sequence, or "" when color is disabled.


[View source]
def yellow : String #

Returns the yellow escape sequence, or "" when color is disabled.


[View source]