lucee.Component
commandbox.system.util.Print
Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I am a helper object for creating pretty ANSI-formatted text in the shell. I use onMissingMethod to allow for nice, readable methods that contain combinations of text and background colors as well as text formatting. Ex. print.Line() print.text( 'Hello World' ); print.boldText( 'Hello World' ); print.line( 'Hello World' ); print.redLine( 'Hello World' ); print.redOnWhiteLine( 'Hello World' ); print.redOnWhiteBold( 'Hello World' ); print.boldBlinkingUnderscoredBlueTextOnRedBackground( 'Test' ); If you want to modify formatting at runtime, pass a second parameter of additional text that will be appended to the method name upon processing. print.text( 'Hello World', 'blue' ); print.text( 'Hello World', statusColor ); print.text( 'Hello World', ( status == 'running' ? 'green' : 'red' ) ); Indent each carriage return with two spaces like so: print.indentedLine( 'Hello World' );
| Property Summary | ||||
|---|---|---|---|---|
| type | property | default | serializable | required |
any
|
JSONService
|
true
|
false
|
|
any
|
colors256Data
|
true
|
false
|
|
any
|
cr
|
true
|
false
|
|
any
|
formatterUtil
|
true
|
false
|
|
any
|
shell
|
true
|
false
|
|
any
|
tablePrinter
|
true
|
false
|
|
| Method Summary | |
|---|---|
private any
|
_onMissingMethod([any missingMethodName], [any missingMethodArguments])
|
private any
|
_tree(struct parent, string prefix, any formatUDF, any treeSB, [Array keyPath='[runtime expression]'])
|
string
|
columns(array items, [any formatUDF='[runtime expression]'])
|
private string
|
get256Color(any id, [any foreground='true'])
Get an 256 color ANSI. |
private string
|
getANSIAttribute(any attribute)
Get an ANSI Attribute. |
private string
|
indent([any text])
Pad all lines with 2 spaces. |
any
|
onMissingMethod([any missingMethodName], [any missingMethodArguments])
This allows you concatenate pretty method names to describe the kind of text you want to generate. |
private string
|
padRight(string text, numeric maxWidth, [string padChar=' '])
Adds characters to the right of a string until the string reaches a certain length. |
any
|
table(any data='[runtime expression]', [any includedHeaders=''], [any headerNames=''], [boolean debug='false'], [any width='-1'])
Outputs a table to the screen. |
any
|
tree(struct data, [any formatUDF='[runtime expression]'])
|
any
|
unansi(any ansiString)
Removes ANSI attributes from string. |
| Methods inherited from class lucee.Component |
|---|
| None |
| Property Detail |
|---|
access - publicrequired - falsereturntype - anyinject - JSONServiceserializable - trueaccess - publicrequired - falsereturntype - anyinject - colors256Data@constantsserializable - trueaccess - publicrequired - falsereturntype - anyinject - cr@constantsserializable - trueaccess - publicrequired - falsereturntype - anyinject - formatterserializable - trueaccess - publicrequired - falsereturntype - anyinject - shellserializable - trueaccess - publicrequired - falsereturntype - anyinject - provider:TablePrinterserializable - true| Method Detail |
|---|
missingMethodNamemissingMethodArgumentsparentprefixformatUDFtreeSBkeyPathitemsformatUDFGet an 256 color ANSI
idforegroundGet an ANSI Attribute
attributePad all lines with 2 spaces
textThis allows you concatenate pretty method names to describe the kind of text you want to generate If the method name contains "line", it will be appended with a carriage return Any other token in the name that exists in the list of ANSI attributes above will be picked up and applied to the text
missingMethodNamemissingMethodArgumentsAdds characters to the right of a string until the string reaches a certain length. If the text is already greater than or equal to the maxWidth, the text is returned unchanged.
text - The text to pad.maxWidth - The number of characters to pad up to.padChar - The character to use to pad the text.Outputs a table to the screen an array in the correct order matching the number of headers or a struct with keys matching the headers.
data - Any type of data for the table. Each item in the array may either beincludedHeaders - A list of headers to include. Used for query inputsheaderNames - An list/array of column headers to use instead of the defaultdebug - Only print out the names of the columns and the first row valueswidth - Override the terminal widthdata - top level structformatUDFRemoves ANSI attributes from string
ansiString