Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • CommandUtils

Index

Methods

Static Private addChildAndDescendantsToSearch

  • 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

  • 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 flattenCommandTreeWithAliases

Static getFullCommandName

Static getOptionDefinitionFromName

Static optionWasSpecified

  • optionWasSpecified(optionName: string, commandDefinition: ICommandDefinition, args: ICommandArguments["args"]): boolean
  • 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
  • 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