Constructors

  • Create a unix-like argument parser to extract flags from the argument list. Can also create help messages.

    Parameters

    • name: string

      Script name

    • desc: string

      Help description

    • argList: (ArgParser | Arg<any>)[] = []

      Array of CLI arguments

    • examples: string[] = []

      Additional examples to display

    Returns ArgParser

Properties

argList: (ArgParser | Arg<any>)[] = []

Array of CLI arguments

args: Arg<any>[] = []
commands: ArgParser[] = []
defaults: {
    [key: string]: any;
}
desc: string

Help description

examples: string[] = []

Additional examples to display

flags: Arg<any>[] = []
name: string

Script name

Methods

  • Create help message from the provided description & argument list.

    Parameters

    • opts: {
          command?: string;
          message?: string;
      } = {}

      Help options: command - display a commands help, message - override help description

      • Optionalcommand?: string
      • Optionalmessage?: string

    Returns string

    Help message

  • Parse an array into an arguments dictionary using the configuration.

    Parameters

    • args: string[]

      Array of arguments to be parsed

    Returns any

    Dictionary of arguments with defaults applied