notes.dt.in.th

The @rushstack/ts-command-line library is used by many Node.js CLI tools developed by Microsoft, such as Heft, API Documenter and API Extractor.

Boilerplate

To use this boilerplate:

  1. Copy the code below.
  2. Rename AppCommandLineParser
  3. Rename AppCommandLineAction
  4. Fix things in fixme
import {
  CommandLineAction,
  CommandLineParser,
} from '@rushstack/ts-command-line'

class AppCommandLineParser extends CommandLineParser {
  public constructor() {
    super({
      toolFilename: 'fixme',
      toolDescription: 'fixme',
    })
    this.addAction(new AppCommandLineAction())
  }
  protected onDefineParameters(): void {
    // fixme
  }
}

class AppCommandLineAction extends CommandLineAction {
  public constructor() {
    super({
      actionName: 'fixme',
      summary: 'fixme',
      documentation: 'fixme',
    })
  }
  protected onDefineParameters(): void {
    // fixme
  }
  protected async onExecute(): Promise<void> {
    // fixme
    console.log('Hello!')
  }
}

new AppCommandLineParser().execute()