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

- ICommandResponseApi

## Index

### Constructors

- constructor

### Properties

- mArguments
- mConsoleApi
- mControl
- mData
- mDataApi
- mDefinition
- mError
- mExitCode
- mFormatApi
- mMessage
- mPrimaryTextColor
- mProgressApi
- mProgressBar
- mProgressBarSpinnerChars
- mResponseFormat
- mSilent
- mStderr
- mStdout
- mStream
- mSucceeded
- MAX_COLUMN_WIDTH
- RESPONSE_ERR_TAG

### Accessors

- console
- control
- data
- format
- progress
- responseFormat
- silent

### Methods

- bufferStderr
- bufferStdout
- buildJsonResponse
- endProgressBar
- endStream
- failed
- formatMessage
- setDaemonExitCode
- setError
- succeeded
- write
- writeAndBufferStderr
- writeAndBufferStdout
- writeJsonResponse
- writeStderr
- writeStdout
- writeStream

## Constructors

### constructor

- new CommandResponse(params?: ICommandResponseParms): CommandResponse

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:211

  Creates an instance of CommandResponse.

  memberof

    CommandResponse

  #### Parameters

  - ##### Optional params: ICommandResponseParms

    See the interface for details.

  #### Returns CommandResponse

## Properties

### Private mArguments

mArguments: Arguments

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:203

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

memberof

  CommandResponse

### Private mConsoleApi

mConsoleApi: IHandlerResponseConsoleApi

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:167

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

memberof

  CommandResponse

### Private mControl

mControl: ICommandResponseParms

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:76

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

memberof

  CommandResponse

### Private mData

mData: any

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:131

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

memberof

  CommandResponse

### Private mDataApi

mDataApi: IHandlerResponseDataApi

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:160

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

memberof

  CommandResponse

### Private mDefinition

mDefinition: ICommandDefinition

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:195

The command definition document - may be undefined/null

memberof

  CommandResponse

### Private mError

mError: IImperativeError

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:139

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

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:97

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

memberof

  CommandResponse

### Private mFormatApi

mFormatApi: IHandlerFormatOutputApi

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:174

Format APIs for automatically formatting output data

memberof

  CommandResponse

### Private mMessage

mMessage: string = ""

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:124

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

memberof

  CommandResponse

### Private mPrimaryTextColor

mPrimaryTextColor: string = Constants.DEFAULT_HIGHLIGHT_COLOR

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:103

The default highlight color for chalk

memberof

  CommandResponse

### Private mProgressApi

mProgressApi: IHandlerProgressApi

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:153

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

memberof

  CommandResponse

### Private mProgressBar

mProgressBar: any

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:146

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

memberof

  CommandResponse

### Private mProgressBarSpinnerChars

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

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:188

The progress bar spinner chars.

memberof

  CommandResponse

### Private mResponseFormat

mResponseFormat: COMMAND_RESPONSE_FORMAT

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:181

The command response format - JSON, default, etc.

memberof

  CommandResponse

### Private mSilent

mSilent: boolean = false

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:83

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

memberof

  CommandResponse

### Private mStderr

mStderr: Buffer = Buffer.alloc(0)

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:110

The stderr buffer - collects all messages sent to stderr.

memberof

  CommandResponse

### Private mStdout

mStdout: Buffer = Buffer.alloc(0)

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:117

The stdout buffer - collects all messages sent to stdout.

memberof

  CommandResponse

### Private mStream

mStream: Socket

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:211

The stream to write to in daemon mode

memberof

  CommandResponse

### Private mSucceeded

mSucceeded: boolean = true

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:90

Command handler succeeded flag - true if the command succeeded.

memberof

  CommandResponse

### Static Private Readonly MAX_COLUMN_WIDTH

MAX_COLUMN_WIDTH: 9999 = 9999

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:69

Max column width for formulating tabular output

static
memberof

  CommandProcessor

### Static Private Readonly RESPONSE_ERR_TAG

RESPONSE_ERR_TAG: string = "Command Response Error:"

- Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:62

Imperative Error tag for error messaging

static
memberof

  CommandResponse

## Accessors

### console

- get console(): IHandlerResponseConsoleApi

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:535

  Accessor for the console API - Handlers will use this API to write console messages.

  readonly
  memberof

    CommandResponse

  #### Returns IHandlerResponseConsoleApi

### Private control

- get control(): ICommandResponseParms

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:1024

  Internal accessor for the full control parameters passed to the command response object.

  readonly
  memberof

    CommandResponse

  #### Returns ICommandResponseParms

### data

- get data(): IHandlerResponseDataApi

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:634

  Accessor for the data api class - Handlers will use this to construct/influence the response JSON object (data is only displayed to the user if JSON mode is requested).

  readonly
  memberof

    CommandResponse

  #### Returns IHandlerResponseDataApi

### format

- get format(): IHandlerFormatOutputApi

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:234

  #### Returns IHandlerFormatOutputApi

### progress

- get progress(): IHandlerProgressApi

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:691

  Accessor for the progress bar API - Handlers will use this API to create/destroy command progress bars.

  readonly
  memberof

    CommandResponse

  #### Returns IHandlerProgressApi

### responseFormat

- get responseFormat(): COMMAND_RESPONSE_FORMAT

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:981

  Accessor for the response format - see the type for available options - controls how the response will be presented to the user (JSON format, default, etc.)

  readonly
  memberof

    CommandResponse

  #### Returns COMMAND_RESPONSE_FORMAT

### silent

- get silent(): boolean

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:873

  Accessor for the silent flag - silent indicates that the command produces absolutely no output to the console.

  readonly
  memberof

    CommandResponse

  #### Returns boolean

## Methods

### bufferStderr

- bufferStderr(data: Buffer | string): void

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:909

  Buffer the message (string or buffer) to the stderr buffer. Used to accumulate messages for different reasons (JSON mode is enabled, etc.).

  memberof

    CommandResponse

  #### Parameters

  - ##### data: Buffer | string

    The data/messages to buffer.

  #### Returns void

### bufferStdout

- bufferStdout(data: Buffer | string): void

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:899

  Buffer the message (string or buffer) to the stdout buffer. Used to accumulate messages for different reasons (JSON mode is enabled, etc.).

  memberof

    CommandResponse

  #### Parameters

  - ##### data: Buffer | string

    The data/messages to buffer.

  #### Returns void

### buildJsonResponse

- buildJsonResponse(): ICommandResponse

- Implementation of ICommandResponseApi.buildJsonResponse

  - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:928

  Returns the JSON response for the command.

  memberof

    CommandResponse

  #### Returns ICommandResponse

  - The command JSON response - See the interface for details.

### endProgressBar

- endProgressBar(): void

- Implementation of ICommandResponseApi.endProgressBar

  - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:989

  Complete any outstanding progress bars.

  memberof

    CommandResponse

  #### Returns void

### Private endStream

- endStream(): void

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:1000

  Explicitly end a stream

  memberof

    CommandResponse

  #### Returns void

### failed

- failed(): void

- Implementation of ICommandResponseApi.failed

  - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:881

  Setter for the succeeded flag (sets to false to indicate command failure).

  memberof

    CommandResponse

  #### Returns void

### Private formatMessage

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

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:1036

  Uses text utils to format the message (format strings).

  memberof

    CommandResponse

  #### Parameters

  - ##### msg: string

    The format message

  - ##### Rest ...values: any[]

    The substitution values for the format string

  #### Returns string

  - Returns the formatted message

### Private setDaemonExitCode

- setDaemonExitCode(): void

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:1013

  Send headers to daemon client

  memberof

    CommandResponse

  #### Returns void

### setError

- setError(error: IImperativeError): void

- Implementation of ICommandResponseApi.setError

  - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:919

  Setter for the error object in the response - automatically populated by the Command Processor if the handler rejects the handler promise.

  memberof

    CommandResponse

  #### Parameters

  - ##### error: IImperativeError

    The error object to place in the response.

  #### Returns void

### succeeded

- succeeded(): void

- Implementation of ICommandResponseApi.succeeded

  - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:889

  Setter for the succeeded flag (sets to true to indicate command success).

  memberof

    CommandResponse

  #### Returns void

### Private write

- write(): boolean

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:1107

  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

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:1082

  Buffers to stderr and optionally prints the msg to the console.

  memberof

    CommandResponse

  #### Parameters

  - ##### data: Buffer | string

    The data to write/buffer

  #### Returns void

### Private writeAndBufferStdout

- writeAndBufferStdout(data: Buffer | string): void

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:1046

  Buffers to stdout and optionally prints the msg to the console.

  memberof

    CommandResponse

  #### Parameters

  - ##### data: Buffer | string

    The data to write/buffer

  #### Returns void

### writeJsonResponse

- writeJsonResponse(): ICommandResponse

- Implementation of ICommandResponseApi.writeJsonResponse

  - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:951

  Writes the JSON response to the console - Done normally by the command processor dependending on the response format specified in the object.

  memberof

    CommandResponse

  #### Returns ICommandResponse

  - Returns the constructed response that is written to the console.

### Private writeStderr

- writeStderr(data: Buffer | string): void

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:1095

  Writes the data to stderr

  memberof

    CommandResponse

  #### Parameters

  - ##### data: Buffer | string

    the data to write to stderr

  #### Returns void

### Private writeStdout

- writeStdout(data: Buffer | string): void

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:1059

  Writes the data to stdout

  memberof

    CommandResponse

  #### Parameters

  - ##### data: Buffer | string

    the data to write

  #### Returns void

### Private writeStream

- writeStream(data: Buffer | string): void

- - Defined in @zowe/imperative/src/cmd/src/response/CommandResponse.ts:1070

  Writes data to stream if provided (for daemon mode)

  memberof

    CommandResponse

  #### Parameters

  - ##### data: Buffer | string

  #### Returns void

Generated using TypeDoc