Command utility class. Place static utils for command processing here.

### Hierarchy

- CommandUtils

## Index

### Methods

- addChildAndDescendantsToSearch
- flattenCommandTree
- getFullCommandName
- getOptionDefinitionFromName
- optionWasSpecified
- reconstructCommand

## Methods

### Static Private addChildAndDescendantsToSearch

- addChildAndDescendantsToSearch(prefix: string, child: ICommandDefinition, includeAliases?: boolean, _result?: ICommandTreeEntry[], _tree?: ICommandDefinition): ICommandTreeEntry[]

- - Defined in @zowe/imperative/src/cmd/src/utils/CommandUtils.ts:127

  Helper recursive function for flattening a given tree definition

  #### Parameters

  - ##### prefix: string

    Previous command objects to prepend to the given child name

  - ##### child: ICommandDefinition

    Tree definition to use when searching for descendants

  - ##### Default value includeAliases: boolean = false

    Indicates whether or not we should include aliases in the recursion

  - ##### Default value _result: ICommandTreeEntry[] = []

    (recursion) resulting list of flattened descendants

  - ##### Default value _tree: ICommandDefinition = child

    (recursion) Initial tree definition

  #### Returns ICommandTreeEntry[]

  Concatenated list of flattened descendants

### Static flattenCommandTree

- flattenCommandTree(tree: ICommandDefinition, includeAliases?: boolean): ICommandTreeEntry[]

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

  Accepts the command definition document tree and flattens to a single level. This is used to make searching commands and others easily.

  #### Parameters

  - ##### tree: ICommandDefinition

    The command document tree

  - ##### Default value includeAliases: boolean = false

    Indicates whether or not we should include aliases in the flattened command tree

  #### Returns ICommandTreeEntry[]

  - The flattened document tree

### Static getFullCommandName

- getFullCommandName(commandDef: ICommandDefinition, commandTree: ICommandDefinition): string

- - Defined in @zowe/imperative/src/cmd/src/utils/CommandUtils.ts:177

  TODO - This needs to be well tested TODO - There is a situation where two groups could have the same child command TODO - It appears to choose the last in the list

  static
  memberof

    CommandUtils

  #### Parameters

  - ##### commandDef: ICommandDefinition

  - ##### commandTree: ICommandDefinition

  #### Returns string

### Static getOptionDefinitionFromName

- getOptionDefinitionFromName(optionName: string, commandDefinition: ICommandDefinition): ICommandOptionDefinition

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

  Find the option definition from the .options field of the command definition

  #### Parameters

  - ##### optionName: string

  - ##### commandDefinition: ICommandDefinition

    the definition for the command

  #### Returns ICommandOptionDefinition

  - if the optionName is an option,

                                              the definition of the option, otherwise undefined

### Static optionWasSpecified

- optionWasSpecified(optionName: string, commandDefinition: ICommandDefinition, args: ICommandArguments["args"]): boolean

- - Defined in @zowe/imperative/src/cmd/src/utils/CommandUtils.ts:83

  Check if an option was specified by the user.

  #### Parameters

  - ##### optionName: string

    the option to check for.

  - ##### commandDefinition: ICommandDefinition

    the definition for the command

  - ##### args: ICommandArguments["args"]

  #### Returns boolean

  true: the option was specified by the user. false: the option was omitted/set to false

### Static reconstructCommand

- reconstructCommand(commandArguments: Arguments, commandDefinition: ICommandDefinition): string

- - Defined in @zowe/imperative/src/cmd/src/utils/CommandUtils.ts:47

  Get a representation of the original command as issued by the user .with all canonical forms of options specified. You only need to supply the "command" segement of your command. The "full command" (including previous groups, etc.) is extracted from the yargs arguments object "_" property. TODO: Replace "maincommand" below with the name of the bin - This is new to Imperative.

  #### Parameters

  - ##### commandArguments: Arguments

    The Yargs style argument object. Requires the "_" (input argv)

  - ##### commandDefinition: ICommandDefinition

    The command definition document

  #### Returns string

  - The reconstructed command (as would have been issued on the console).

Generated using TypeDoc