Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CommandResponse

Command response object allocated by the command processor and used to construct the handler response object passed to the command handlers. The response object contains all the methods necessary for a command handler (and the processor) to formulate a command response. Controls buffering of messages and JSON response formats.

Instances of this class are only manipulated by the command processor. See "HandlerResponse" for the handler response object.

export
implements

{ICommandResponseApi}

Hierarchy

  • CommandResponse

Implements

Index

Constructors

constructor

Properties

Private mArguments

mArguments: Arguments

The arguments passed to the command - may be undefined/null

memberof

CommandResponse

Private mConsoleApi

API instance for the console APIs - used to write messages to stdout/stderr.

memberof

CommandResponse

Private mControl

The full set of control parameters for the response - see the interface for details.

memberof

CommandResponse

Private mData

mData: any

The "data" object that is placed on the JSON response object of the command

memberof

CommandResponse

Private mDataApi

API instance for the data APIs - used to populate the JSON response object fields.

memberof

CommandResponse

Private mDefinition

mDefinition: ICommandDefinition

The command definition document - may be undefined/null

memberof

CommandResponse

Private mError

The error object appended to the JSON response to the command - automatically added if the handler rejects the promise.

memberof

CommandResponse

Private mExitCode

mExitCode: number = null

Command handler exit code. Will be used when exiting the process at the end of command execution

memberof

CommandResponse

Private mFormatApi

Format APIs for automatically formatting output data

memberof

CommandResponse

Private mMessage

mMessage: string = ""

The message placed on the response object when the JSON response is built

memberof

CommandResponse

Private mPrimaryTextColor

mPrimaryTextColor: string = Constants.DEFAULT_HIGHLIGHT_COLOR

The default highlight color for chalk

memberof

CommandResponse

Private mProgressApi

mProgressApi: IHandlerProgressApi

API instance for the progress bar - used to create/end command progress bars.

memberof

CommandResponse

Private mProgressBar

mProgressBar: any

Progress bar instance - only one can be present at any given time.

memberof

CommandResponse

Private mProgressBarSpinnerChars

mProgressBarSpinnerChars: string = "-oO0)|(0Oo-"

The progress bar spinner chars.

memberof

CommandResponse

Private mResponseFormat

mResponseFormat: COMMAND_RESPONSE_FORMAT

The command response format - JSON, default, etc.

memberof

CommandResponse

Private mSilent

mSilent: boolean = false

Enable silent mode - means absolutely NO output will be written to the console/terminal.

memberof

CommandResponse

Private mStderr

mStderr: Buffer = Buffer.alloc(0)

The stderr buffer - collects all messages sent to stderr.

memberof

CommandResponse

Private mStdout

mStdout: Buffer = Buffer.alloc(0)

The stdout buffer - collects all messages sent to stdout.

memberof

CommandResponse

Private mSucceeded

mSucceeded: boolean = true

Command handler succeeded flag - true if the command succeeded.

memberof

CommandResponse

Static Private Readonly MAX_COLUMN_WIDTH

MAX_COLUMN_WIDTH: 9999 = 9999

Max column width for formulating tabular output

static
memberof

CommandProcessor

Static Private Readonly RESPONSE_ERR_TAG

RESPONSE_ERR_TAG: string = "Command Response Error:"

Imperative Error tag for error messaging

static
memberof

CommandResponse

Accessors

console

Private control

data

format

progress

responseFormat

silent

  • get silent(): boolean

Methods

bufferStderr

  • bufferStderr(data: Buffer | string): void

bufferStdout

  • bufferStdout(data: Buffer | string): void

buildJsonResponse

endProgressBar

  • endProgressBar(): void

failed

  • failed(): void

Private formatMessage

  • formatMessage(msg: string, ...values: any[]): string

setError

succeeded

  • succeeded(): void

Private write

  • write(): boolean
  • Indicates if output should be written immediately to the console/terminal. If silent mode is true or response format indicates JSON, then write() will return false.

    memberof

    CommandResponse

    Returns boolean

    • True if the output should be written to the console/terminal.

Private writeAndBufferStderr

  • writeAndBufferStderr(data: Buffer | string): void

Private writeAndBufferStdout

  • writeAndBufferStdout(data: Buffer | string): void

writeJsonResponse

Private writeStderr

  • writeStderr(data: any): void

Private writeStdout

  • writeStdout(data: any): void

Generated using TypeDoc