Options
All
  • Public
  • Public/Protected
  • All
Menu

The main entrypoint for CLI argv parsing and execution

Hierarchy

  • CLI

Index

Constructors

constructor

  • Creates a new CLI parser instance

    const cli = new CLI({
      baseDir: __dirname,
      commandDir: './relative/path/to/my/command/impls',
      commandDelim: ':', // use colons instead of spaces to traverse command tree
    });

    Parameters

    • Optional options: ICLIOptions

      configurations or overrides to package.json configuration

    Returns CLI

Properties

logger

logger: Logger = new Log.Logger({name: this.constructor.name})

program

program: Program

Methods

addGlobalHelp

  • addGlobalHelp(heading: string, body?: string, raw?: boolean): CLI
  • Add help text to the main program

    Parameters

    • heading: string

      Add ui heading

    • Optional body: string

      Help text to show

    • Optional raw: boolean

      Flag to output the raw text without formatting

    Returns CLI

addGlobalOption

help

parse

  • parse(argv: string[]): Promise<void>
  • Main execution method. Parse arguments from the command line and run the program.

    import { CLI } from '@jib/cli';
    
    const parser = new CLI({
      // options
    });
    parser.parse(process.argv);

    Parameters

    • argv: string[]

      raw command line arguments

    Returns Promise<void>