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.

optionsTPrintOptions<optional>
{}

Options object.

Members

buildText

Translate, prefixed with counter and/or datetime etc.

options :TPrintOptions

Options object.

ora

ora instance

See

startTime :Object

Time when instance is created.

Type:
  • Object
See

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)

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

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.

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(argsopt)

Setting spinner options; override the one passed at constructor.

Parameters:
NameTypeAttributesDefaultDescription
argsArray.<any><optional>
[]

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

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
optionsTPrintOptions<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