Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CommandLine

The parser transforms a CLI (a model) into an CommandLine. This CommandLine has stored the argument and option values. Only instance of parser should create objects of this type.

Hierarchy

  • CommandLine

Index

Methods

acceptMoreValues

  • acceptMoreValues(option: Option): boolean
  • Checks whether or not the given option accept more values.

    Parameters

    Returns boolean

allArguments

  • allArguments(): string
  • Returns string

cli

  • Returns CLI

getArgumentValue

  • getArgumentValue<T>(name: string): T | null
  • getArgumentValue<T>(index: number): T | null
  • Gets the value of an argument with the matching name (arg name).

    Type parameters

    • T

    Parameters

    • name: string

    Returns T | null

  • Gets the value of an argument with the given index.

    Type parameters

    • T

    Parameters

    • index: number

    Returns T | null

getOptionValue

  • getOptionValue<T>(name: string): T | null
  • Gets the value of an option with the matching name (can be the long name, short name or arg name).

    Type parameters

    • T

    Parameters

    • name: string

    Returns T | null

getRawValueForArgument

  • getRawValueForArgument(arg: Argument): string | null
  • Gets the raw value of the given argument. Raw values are the values as given in the user command line.

    Parameters

    Returns string | null

getRawValueForOption

  • getRawValueForOption(option: Option): string | null
  • Gets the raw value of the given option. Raw values are the values as given in the user command line.

    Parameters

    Returns string | null

getRawValues

  • getRawValues(option: Option): string
  • Gets the raw values of the given option. Raw values are simple "String", not converted to the option type.

    Parameters

    Returns string

getRawValuesForArgument

  • getRawValuesForArgument(argument: Argument): string
  • Gets the raw values of the given argument. Raw values are simple "String", not converted to the argument type.

    Parameters

    Returns string

getRawValuesForOption

  • getRawValuesForOption(option: Option): string
  • Gets the raw values of the given option. Raw values are simple "String", not converted to the option type.

    Parameters

    Returns string

isArgumentAssigned

  • isArgumentAssigned(arg: Argument): boolean
  • Checks whether or not the given argument has been assigned in the command line.

    Parameters

    Returns boolean

isAskingForHelp

  • isAskingForHelp(): boolean
  • Checks whether or not the user has passed a "help" option and is asking for help.

    Returns boolean

isFlagEnabled

  • isFlagEnabled(name: string): boolean
  • Gets the value of an option marked as a flag.

    Calling this method an a non-flag option throws an IllegalStateException.

    Parameters

    • name: string

    Returns boolean

isOptionAssigned

  • isOptionAssigned(option: Option): boolean
  • Checks whether or not the given option has been assigned in the command line.

    Parameters

    Returns boolean

isSeenInCommandLine

  • isSeenInCommandLine(option: Option): boolean
  • Checks whether or not the given option has been seen in the user command line.

    Parameters

    Returns boolean

isValid

  • isValid(): boolean
  • Checks whether or not the command line is valid, i.e. all constraints from arguments and options have been satisfied. This method is used when the parser validation is disabled.

    Returns boolean

Static create

  • Creates a command line object from the CLI. This object is intended to be used by the parser to set the argument and option values.

    Parameters

    Returns CommandLine

Generated using TypeDoc