interface PrinterService

Service allowing a Command to output user messages to stdout and/or stderr.

Output to stdout is via print whilst output to stderr is via a filtered logging mechanism using debug, info, warn and error.

Properties

Disable or enable color output for messages.

darkMode: boolean

Enable or disable dark mode. Default is disabled i.e. false.

The WritableStream used for stdout. Can be accessed directly for output of binary data etc.

The WritableStream used for stderr. Can be accessed directly for output of binary data etc.

Methods

primary(message: string): string

Return the provided message so that the foreground is colored as primary content. This is the default calor applied. The actual color will depend on the value of darkMode. Has no effect if colorEnabled is false.

secondary(message: string): string

Return the provided message so that the foreground is colored as secondary content. The actual color will depend on the value of darkMode. Has no effect if colorEnabled is false.

emphasised(message: string): string

Return the provided message so that the foreground is colored as emphasised content. The actual color will depend on the value of darkMode. Has no effect if colorEnabled is false.

selected(message: string): string

Return the provided message so that the background is colored as selected content. The actual color will depend on the value of darkMode. Has no effect if colorEnabled is false.

italic(message: string): string

Return the provided message so that the text is displayed in italic.

yellow(message: string): string

Return the provided message so that the foreground is yellow. Has no effect if colorEnabled is false.

orange(message: string): string

Return the provided message so that the foreground is orange. Has no effect if colorEnabled is false.

red(message: string): string

Return the provided message so that the foreground is red. Has no effect if colorEnabled is false.

magenta(message: string): string

Return the provided message so that the foreground is magenta. Has no effect if colorEnabled is false.

violet(message: string): string

Return the provided message so that the foreground is violet. Has no effect if colorEnabled is false.

blue(message: string): string

Return the provided message so that the foreground is blue. Has no effect if colorEnabled is false.

cyan(message: string): string

Return the provided message so that the foreground is cyan. Has no effect if colorEnabled is false.

green(message: string): string

Return the provided message so that the foreground is green. Has no effect if colorEnabled is false.

color(
message: string,
hexFormattedColor: string,
): string

Return the provided message so that the foreground is the specified color. Has no effect if colorEnabled is false.

print(
message: string,
icon?: Icon,
): Promise<void>

Print a message on stdout. Will be displayed as primary content if colorEnabled is true.

debug(
message: string,
icon?: Icon,
): Promise<void>

Print a DEBUG level message on stderr. Will be displayed as secondary content if colorEnabled is true.

info(
message: string,
icon?: Icon,
): Promise<void>

Print an INFO level message on stderr. Will be displayed as primary content if colorEnabled is true.

warn(
message: string,
icon?: Icon,
): Promise<void>

Print a WARN level message on stderr. Will be displayed as yellow content if colorEnabled is true.

error(
message: string,
icon?: Icon,
): Promise<void>

Print an ERROR level message on stderr. Will be displayed as red content if colorEnabled is true.

setLevel(level: Level): void

Set the output threshold Level for stderr.

Default level is INFO.

Get the output threshold Level for stderr.

showSpinner(message: string): Promise<void>

Display the spinner on stderr.

The spinner will be displayed as emphasised content and the message will be displayed as primary content if colorEnabled is true.

NOTE: The spinner and message will be displayed at INFO level.

NOTE: If the spinner is already displayed the message will be updated to that specified.

NOTE: If any progress bars are currently displayed they will be hidden.

hideSpinner(): Promise<void>

Hide the spinner.

NOTE: Showing a progress bar will also hide the spinner.

showProgressBar(
units: string,
message?: string,
total?: number,
current?: number,
): Promise<number>

Display a progress bar on stderr.

The progress will be displayed in green if colorEnabled is true.

NOTE: The progress bar and message will be displayed at INFO level.

NOTE: If the spinner is currently displayed it will be hidden.

hideProgressBar(handle: number): Promise<void>

Hides a specified progress bar.

NOTE: Showing the spinner will also hide ALL progress bars.

hideAllProgressBars(): Promise<void>

Hides all progress bars.

NOTE: Showing the spinner will also hide ALL progress bars.

updateProgressBar(
handle: number,
current: number,
message?: string,
): void

Update a specific progress bar.