module

Fluxion::CLI::Style

Terminal styling.

Colour is decided once, here, from whether stdout is a terminal and whether the user asked for it to be off. Every renderer then styles unconditionally and gets plain text automatically when it is piped into a file, a pager, or CI — which is what makes the output safe to parse without a --no-color flag on every command.

Constants

COLORS = { black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, white: 37, gray: 90, }

A named palette rather than raw codes at the call sites, so the meaning of a colour is stated once and stays consistent across commands.

FORCE_COLOR = "FORCE_COLOR"

The conventional override for the opposite case: colour in a pipe.

NO_COLOR = "NO_COLOR"

https://no-color.org — set to anything, colour goes away.

RESET = "\e[0m"

Instance methods

black(text) : String
Source
blue(text) : String
Source
bold(text) : String
Source
bold_blue(text) : String
Source
bold_cyan(text) : String
Source
bold_green(text) : String
Source
bold_red(text) : String
Source
bold_yellow(text) : String
Source
cyan(text) : String
Source
dim(text) : String
Source
enabled=(value : Bool | Nil) : Nil
Source
enabled?
Source
gray(text) : String
Source
green(text) : String
Source
italic(text) : String
Source
magenta(text) : String
Source
pad(text : String, size : Int32) : String

Pads to size columns using the visible width.

Source
red(text) : String
Source
strip(text : String) : String
Source
truncate(text : String, size : Int32) : String

Truncates to size columns, marking that something was cut.

Source
underline(text) : String
Source
white(text) : String
Source
width(text : String) : Int32

Display width, ignoring the escape sequences styling added.

Column alignment has to measure what the user sees, not what is in the string, or every styled table drifts.

Source
with_color(value : Bool, &)

Runs a block with colour forced on or off, restoring it afterwards.

Source
yellow(text) : String
Source