Print

Universal print engine, supports text translation using app's built-in translation.

Features many methods to display things on screen/console using ora based spinner.

Constructor

new Print(plugin, optionsopt)

Parameters:
NameTypeAttributesDefaultDescription
pluginPlugin

Plugin instance.

optionsPrint.TOptions<optional>
{}

Options object.

Members

buildText

Translate text, prefixed with counter and/or datetime etc.

options :Print.TOptions

Options object.

ora

ora instance

See

startTime :Object

Start time of the instance, used to calculate elapsed time.

Type:
  • Object

Methods

clear() → {Print}

Clear spinner text.

Returns:

Return the instance itself, usefull for method chaining

Type: 
Print

fail(text, …argsopt) → {Print}

Print failed message, prefixed with a cross icon.

Parameters:
NameTypeAttributesDescription
textstring

Text to use

argsany<optional>
<repeatable>

Any variable to interpolate text. If the last argument is an object, it will be used to override ora options

Returns:

Return the instance itself, usefull for method chaining

Type: 
Print

fatal(text, …argsopt) → {void}

Print failed message, prefixed with a cross icon and exit application abruptly.

Parameters:
NameTypeAttributesDescription
textstring

Text to use

argsany<optional>
<repeatable>

Any variable to interpolate text. If the last argument is an object, it will be used to override ora options

Returns:
Type: 
void

getElapsed(unitopt) → {string}

Get elapsed time since instance is created.

Parameters:
NameTypeAttributesDefaultDescription
unitstring<optional>
'hms'

Unit's time. Put 'hms' (default) to get hour, minute, second format or of any format supported by dayjs

Returns:

Elapsed time since start

Type: 
string

info(text, …argsopt) → {Print}

Print information message, prefixed with an info icon.

Parameters:
NameTypeAttributesDescription
textstring

Text to use

argsany<optional>
<repeatable>

Any variable to interpolate text. If the last argument is an object, it will be used to override ora options

Returns:

Return the instance itself, usefull for method chaining

Type: 
Print

render() → {Print}

Force render spinner.

Returns:

Return the instance itself, usefull for method chaining

Type: 
Print

setOpts() → {void}

Setting spinner options; override the one passed at constructor.

Parameters:
TypeDescription
Array.<any>

[args=[]] Array of options. If the last argument is an object, it will be used to override ora options

Returns:
Type: 
void

setText(text, …argsopt) → {Print}

Set spinner's text,

Parameters:
NameTypeAttributesDescription
textstring

Text to use

argsany<optional>
<repeatable>

Any variable to interpolate text. If the last argument is an object, it will be used to override ora's options

Returns:

Return the instance itself, usefull for method chaining

Type: 
Print

spinner(optionsopt) → {Print}

Create a new print instance.

Parameters:
NameTypeAttributesDescription
optionsApp.TOptions<optional>

Options object. If not provided, defaults to the current options.

Returns:

Return new print instance.

Type: 
Print

start(text, …argsopt) → {Print}

Start the spinner.

Parameters:
NameTypeAttributesDescription
textstring

Text to use

argsany<optional>
<repeatable>

Any variable to interpolate text. If the last argument is an object, it will be used to override ora's options

Returns:

Return the instance itself, usefull for method chaining

Type: 
Print

stop() → {Print}

Stop the spinner.

Returns:

Return the instance itself, usefull for method chaining

Type: 
Print

succeed(text, …argsopt) → {Print}

Print success message, prefixed with a check icon

Parameters:
NameTypeAttributesDescription
textstring

Text to use

argsany<optional>
<repeatable>

Any variable to interpolate text. If the last argument is an object, it will be used to override ora options.

Returns:

Return the instance itself, usefull for method chaining

Type: 
Print

warn(text, …argsopt) → {Print}

Print warning message, prefixed with a warn icon.

Parameters:
NameTypeAttributesDescription
textstring

Text to use

argsany<optional>
<repeatable>

Any variable to interpolate text. If the last argument is an object, it will be used to override ora options

Returns:

Return the instance itself, usefull for method chaining

Type: 
Print

Type Definitions

TOptions

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
showDatetimeboolean<optional>
false

Show actual date & time

showCounterboolean<optional>
false

Show as counter

silentboolean<optional>

Suppress any messages. Defaults to the one set in config

oraObject<optional>

Ora's options object