class CLI (View source)

Class to facilitate command-line output.

Support less-trivial output stuff such as colours (on xterm-color)

Methods

public static 
supports_colour()

Returns true if the current STDOUT supports the use of colour control codes.

public static 
string
text(string $text, string $fgColour = null, string $bgColour = null, bool $bold = false)

Return text encoded for CLI output, optionally coloured

public static 
string
start_colour(string $fgColour = null, string $bgColour = null, bool $bold = false)

Send control codes for changing text to the given colour

public static 
end_colour()

Send control codes for returning to normal colour

Details

static supports_colour()

Returns true if the current STDOUT supports the use of colour control codes.

static string text(string $text, string $fgColour = null, string $bgColour = null, bool $bold = false)

Return text encoded for CLI output, optionally coloured

Parameters

string $text
string $fgColour

The foreground colour - black, red, green, yellow, blue, magenta, cyan, white. Null is default.

string $bgColour

The foreground colour - black, red, green, yellow, blue, magenta, cyan, white. Null is default.

bool $bold

A boolean variable - bold or not.

Return Value

string

static string start_colour(string $fgColour = null, string $bgColour = null, bool $bold = false)

Send control codes for changing text to the given colour

Parameters

string $fgColour

The foreground colour - black, red, green, yellow, blue, magenta, cyan, white. Null is default.

string $bgColour

The foreground colour - black, red, green, yellow, blue, magenta, cyan, white. Null is default.

bool $bold

A boolean variable - bold or not.

Return Value

string

static end_colour()

Send control codes for returning to normal colour