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:181

  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:124

The command line.

memberof

  CommandProcessor

### Private mCommandRootName

mCommandRootName: string

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

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:174

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:181

The context object defined when in daemon mode.

memberof

  CommandProcessor

### Private mDefinition

mDefinition: ICommandDefinition

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

The command definition node for the command being executed.

memberof

  CommandProcessor

### Private mEnvVariablePrefix

mEnvVariablePrefix: string

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

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:153

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:160

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:167

Imperative Logger instance for logging from the command processor.

memberof

  CommandProcessor

### Private mPromptPhrase

mPromptPhrase: string

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

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:110

The error tag for imperative errors.

static
memberof

  CommandProcessor

## Accessors

### commandLine

- get commandLine(): string

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

  Accessor for the command line

  readonly
  memberof

    CommandProcessor

  #### Returns string

### config

- get config(): Config

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

  Accessor for the app config

  readonly
  memberof

    CommandProcessor

  #### Returns Config

### definition

- get definition(): ICommandDefinition

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

  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:238

  Accessor for the environment variable prefix

  readonly
  memberof

    CommandProcessor

  #### Returns string

### fullDefinition

- get fullDefinition(): ICommandDefinition

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

  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:258

  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:949

  Internal accessor for the logger instance.

  readonly
  memberof

    CommandProcessor

  #### Returns Logger

### promptPhrase

- get promptPhrase(): string

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

  Accessor for the prompt phrase

  readonly
  memberof

    CommandProcessor

  #### Returns string

### rootCommand

- get rootCommand(): string

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

  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:988

  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:961

  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:1029

  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:978

  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:1058

  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:293

  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:857

  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:346

  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:892

  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:744

  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:331

  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:309

  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