The command processor for imperative - accepts the command definition for the command being issued (and a pre-built) response object and validates syntax, loads profiles, instantiates handlers, & invokes the handlers.

export

### Hierarchy

- CommandProcessor

## Index

### Constructors

- constructor

### Properties

- mCommandLine
- mCommandRootName
- mConfig
- mDaemonContext
- mDefinition
- mEnvVariablePrefix
- mFullDefinition
- mHelpGenerator
- mLogger
- mPromptPhrase
- ERROR_TAG

### Accessors

- commandLine
- config
- definition
- envVariablePrefix
- fullDefinition
- helpGenerator
- log
- promptPhrase
- rootCommand

### Methods

- attemptHandlerLoad
- constructResponseObject
- finishResponse
- getStdinStream
- handleHandlerError
- help
- invalidSyntaxNotification
- invoke
- prepare
- showInputsOnly
- validate
- webHelp

## Constructors

### constructor

- new CommandProcessor(params: ICommandProcessorParms): CommandProcessor

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:175

  Creates an instance of CommandProcessor.

  memberof

    CommandProcessor

  #### Parameters

  - ##### params: ICommandProcessorParms

    See the interface for details.

  #### Returns CommandProcessor

## Properties

### Private mCommandLine

mCommandLine: string

- Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:118

The command line.

memberof

  CommandProcessor

### Private mCommandRootName

mCommandRootName: string

- Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:111

The root command name of the CLI (specified in the Imperative Configuration document)

memberof

  CommandProcessor

### Private mConfig

mConfig: Config

- Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:168

Config object used to load profiles from active config layers.

memberof

  CommandProcessor

### Private Optional mDaemonContext

mDaemonContext: IDaemonContext

- Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:175

The context object defined when in daemon mode.

memberof

  CommandProcessor

### Private mDefinition

mDefinition: ICommandDefinition

- Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:140

The command definition node for the command being executed.

memberof

  CommandProcessor

### Private mEnvVariablePrefix

mEnvVariablePrefix: string

- Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:125

Environmental variable name prefix used to construct configuration environmental variables.

memberof

  CommandProcessor

### Private mFullDefinition

mFullDefinition: ICommandDefinition

- Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:147

The full command definition contains all parents/ancestors of the command being executed.

memberof

  CommandProcessor

### Private mHelpGenerator

mHelpGenerator: IHelpGenerator

- Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:154

The help generator to use - normally passed the default generator.

memberof

  CommandProcessor

### Private mLogger

mLogger: Logger = Logger.getImperativeLogger()

- Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:161

Imperative Logger instance for logging from the command processor.

memberof

  CommandProcessor

### Private mPromptPhrase

mPromptPhrase: string

- Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:133

The phrase used to indicate the user wants to enter the value of an argument in a hidden text prompt

memberof

  CommandProcessor

### Static Private Readonly ERROR_TAG

ERROR_TAG: string = "Command Processor Error:"

- Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:104

The error tag for imperative errors.

static
memberof

  CommandProcessor

## Accessors

### commandLine

- get commandLine(): string

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:222

  Accessor for the command line

  readonly
  memberof

    CommandProcessor

  #### Returns string

### config

- get config(): Config

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:262

  Accessor for the app config

  readonly
  memberof

    CommandProcessor

  #### Returns Config

### definition

- get definition(): ICommandDefinition

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:270

  Obtain a copy of the command definition

  #### Returns ICommandDefinition

  : The Zowe Commands definition document.

### envVariablePrefix

- get envVariablePrefix(): string

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:232

  Accessor for the environment variable prefix

  readonly
  memberof

    CommandProcessor

  #### Returns string

### fullDefinition

- get fullDefinition(): ICommandDefinition

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:278

  Obtain a copy of the command definition

  #### Returns ICommandDefinition

  : The Zowe Commands definition document.

### helpGenerator

- get helpGenerator(): IHelpGenerator

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:252

  Accessor for the help generator passed to this instance of the command processor

  readonly
  memberof

    CommandProcessor

  #### Returns IHelpGenerator

### Private log

- get log(): Logger

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:942

  Internal accessor for the logger instance.

  readonly
  memberof

    CommandProcessor

  #### Returns Logger

### promptPhrase

- get promptPhrase(): string

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:242

  Accessor for the prompt phrase

  readonly
  memberof

    CommandProcessor

  #### Returns string

### rootCommand

- get rootCommand(): string

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:212

  Accessor for the root command name

  readonly
  memberof

    CommandProcessor

  #### Returns string

## Methods

### Private attemptHandlerLoad

- attemptHandlerLoad(response: CommandResponse, handlerPath: string): ICommandHandler

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

  Attempt to load a handler

  #### Parameters

  - ##### response: CommandResponse

    command response to use to log errors in case of failure

  - ##### handlerPath: string

    the specified path to the handler, we will attempt to load this

  #### Returns ICommandHandler

### Private constructResponseObject

- constructResponseObject(params: IInvokeCommandParms): CommandResponse

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:954

  Build the response object for the command based on the invoke parameters. The command response object is passed to the handlers to allow them to perform console messages, response JSON construction, progress bars, etc.

  memberof

    CommandProcessor

  #### Parameters

  - ##### params: IInvokeCommandParms

  #### Returns CommandResponse

### Private finishResponse

- finishResponse(response: CommandResponse): ICommandResponse

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:1022

  Finish the response by building the response object and optionally outputting the JSON response depending on the modes selected.

  memberof

    CommandProcessor

  #### Parameters

  - ##### response: CommandResponse

  #### Returns ICommandResponse

### Private getStdinStream

- getStdinStream(): stream.Readable

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:971

  Get stdin stream for the command handler to use. In daemon mode this is a stream of data received from the daemon client. Otherwise it defaults to `process.stdin`.

  #### Returns stream.Readable

  Readable stream containing stdin data

### Private handleHandlerError

- handleHandlerError(handlerErr: Error | string, response: CommandResponse, handlerPath: string): void

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:1051

  Respond to an error encountered when invoking a command handler

  #### Parameters

  - ##### handlerErr: Error | string

    the error that was encountered

  - ##### response: CommandResponse

    a response object to print error messages to

  - ##### handlerPath: string

    path to the handler with which an error was encountered

  #### Returns void

### help

- help(response: CommandResponse): ICommandResponse

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:287

  Generates the help for the command definition passed.

  memberof

    CommandProcessor

  #### Parameters

  - ##### response: CommandResponse

    The command response object

  #### Returns ICommandResponse

### Private invalidSyntaxNotification

- invalidSyntaxNotification(params: IInvokeCommandParms, response: CommandResponse): void

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:850

  This function outputs the final help text when a syntax validation occurs in {@link CommandProcessor#invoke}

  #### Parameters

  - ##### params: IInvokeCommandParms

    The parameters passed to {@link CommandProcessor#invoke}

  - ##### response: CommandResponse

    The response object to output information to.

  #### Returns void

### invoke

- invoke(params: IInvokeCommandParms): Promise<ICommandResponse>

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:340

  Invoke the command handler. Locates and requires the module specified by the command definition document, creates a new object, creates a response object, and invokes the handler. The handler is responsible for fulfilling the promise when complete.

  #### Parameters

  - ##### params: IInvokeCommandParms

    The parameters passed to the invoke function

  #### Returns Promise<ICommandResponse>

  - The promise that is fulfilled. A rejection if the promise indicates a truly exceptional condition (should not occur).

### Private prepare

- prepare(response: CommandResponse, commandArguments: Arguments): Promise<ICommandArguments>

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:885

  Prepare for command execution. Actions such as reading stdin, auto-loading profiles, etc. will occur here before the command handler is invoked.

  #### Parameters

  - ##### response: CommandResponse

  - ##### commandArguments: Arguments

  #### Returns Promise<ICommandArguments>

  : Promise to fulfill when complete.

### Private showInputsOnly

- showInputsOnly(commandParameters: IHandlerParameters): void

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:738

  Print parameters in place for --dry-run in effect

  memberof

    CommandProcessor

  #### Parameters

  - ##### commandParameters: IHandlerParameters

  #### Returns void

### validate

- validate(commandArguments: ICommandArguments, responseObject: CommandResponse): Promise<ICommandValidatorResponse>

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:325

  Validates the input arguments/options for the command (Performs additional validation outside of what Yargs already provides - ideally, we would like to maintain control over all errors and messages for consistency).

  #### Parameters

  - ##### commandArguments: ICommandArguments

  - ##### responseObject: CommandResponse

  #### Returns Promise<ICommandValidatorResponse>

  : Promise to be fulfilled when validation is complete.

### webHelp

- webHelp(inContext: string, response: CommandResponse): ICommandResponse

- - Defined in @zowe/imperative/src/cmd/src/CommandProcessor.ts:303

  Generates the help for the command definition passed.

  memberof

    CommandProcessor

  #### Parameters

  - ##### inContext: string

    Name of page for group/command to jump to

  - ##### response: CommandResponse

    The command response object

  #### Returns ICommandResponse

Generated using TypeDoc