Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CCli

A @carnesen/cli command-line interface (CLI)

Hierarchy

  • CCli

Index

Constructors

Protected constructor

Properties

Private color

color: { blue: any; bold: any; green: any; red: any } = this.options.color ?? cCliColorFactory(this.options.ansi)

Type declaration

  • blue: function
    • blue(text: string): string
  • bold: function
    • bold(text: string): string
  • green: function
    • green(text: string): string
  • red: function
    • red(text: string): string

Private logger

logger: CCliLogger = this.options.logger ?? CCliConsoleLogger.create()

Private options

options: CCliOptions

Private root

root: CCliRoot

Methods

api

  • api(args: string[]): Promise<any>
  • Programmatic interface for the CLI. Mostly used for unit testing

    Parameters

    • args: string[]

      Command-line argument strings

    Returns Promise<any>

    A promise resolving to the command action's return value

Private done

  • done(code?: undefined | number): void
  • Parameters

    • Optional code: undefined | number

    Returns void

Private handleException

  • handleException(exception: any): void

run

  • run(args?: string[]): Promise<number>
  • Run the command-line interface, console.log the result, and process.exit

    Parameters

    • Optional args: string[]

      Command-line arguments to be parsed and passed into the command action. Defaults to process.argv.slice(2) in Node.js.

    Returns Promise<number>

    A promise resolving to the command's exit code

runLine

  • runLine(line?: string): Promise<number>
  • Split a command line into args and call this Cli's run method

    This method is used to implement the pseudo-shell on the @carnesen/cli website and will form the basis of a future REPL feature

    Parameters

    • Default value line: string = ""

      A command line

    Returns Promise<number>

    A promise resolving to the command's exit code

Static create

Generated using TypeDoc and MonoLisa