Options
All
  • Public
  • Public/Protected
  • All
Menu

A base class representing a sub-command in the command-line utility.

Hierarchy

Index

Constructors

constructor

Properties

Protected Readonly logging

logging: Logging

Private optionValues

optionValues: any

Parsed option values.

Accessors

Private appClassApplication

Methods

Protected app

Protected container

debug

  • debug(output: unknown): void
  • Print the given output to the log as debugging text.

    Parameters

    • output: unknown

    Returns void

didRequestUsage

  • didRequestUsage(argv: string[]): boolean
  • Determines if, at any point in the arguments, the help option's short or long flag appears.

    Parameters

    • argv: string[]

    Returns boolean

    • true if the help flag appeared

error

  • error(output: unknown): void
  • Print the given output to the log as error text.

    Parameters

    • output: unknown

    Returns void

getBoundMethod

  • getBoundMethod(methodName: string): (...args: any[]) => any
  • Get the method with the given name from this class, bound to this class.

    Parameters

    • methodName: string

    Returns (...args: any[]) => any

    function

      • (...args: any[]): any
      • Parameters

        • Rest ...args: any[]

        Returns any

Abstract getDescription

  • getDescription(): string
  • Get the usage description of this directive. Should be brief (1 sentence).

    Returns string

getHelpOption

  • Get the flag option that signals help. Usually, this is named 'help' and supports the flags '--help' and '-?'.

    Returns FlagOption<any>

getHelpText

  • getHelpText(): string
  • Optionally, specify a longer usage text that is shown on the directive's --help page.

    Returns string

Abstract getKeywords

  • getKeywords(): string | string[]
  • Get the keyword or array of keywords that will specify this directive.

    example

    If this returns ['up', 'start'], the directive can be run by either of:

    ./ex up
    ./ex start
    

    Returns string | string[]

getMainKeyword

  • getMainKeyword(): string
  • Get the main keyword displayed for this directive.

    example

    If getKeywords() returns ['up', 'start'], this will return 'up'.

    Returns string

getOptions

getResolvedOptions

  • Resolve the array of option definitions to CLIOption instances. Of note, this resolves the string-form definitions to actual CLIOption instances.

    Returns CLIOption<any>[]

Abstract handle

  • handle(argv: string[]): void | Promise<void>
  • Called when the directive is run from the command line.

    The raw arguments are provided as argv, but you are encouraged to use getOptions() and option() helpers to access the parsed options instead.

    Parameters

    • argv: string[]

    Returns void | Promise<void>

info

  • info(output: unknown): void
  • Print the given output to the log as info text.

    Parameters

    • output: unknown

    Returns void

Protected instantiateOptionFromString

  • instantiateOptionFromString(string: string): CLIOption<any>
  • Create an instance of CLIOption based on a string definition of a particular format.

    e.g. '{file name} | canonical name of the resource to create' e.g. '--push -p {value} | the value to be pushed' e.g. '--force -f | do a force push'

    Parameters

    • string: string

    Returns CLIOption<any>

invoke

  • invoke(argv: string[]): Promise<void>
  • Invoke this directive with the specified arguments.

    If usage was requested (see didRequestUsage()), it prints the extended usage info.

    Otherwise, it parses the options from argv and calls handle().

    Parameters

    • argv: string[]

    Returns Promise<void>

Protected make

  • make<T>(target: any, ...parameters: any[]): T

matchesKeyword

  • matchesKeyword(name: string): boolean
  • Returns true if the given keyword should invoke this directive.

    Parameters

    • name: string

    Returns boolean

Protected nativeOutput

  • nativeOutput(...outputs: any[]): void

option

  • option(name: string, defaultValue?: unknown): any
  • Get the value of a parsed option. If none exists, return defaultValue.

    Parameters

    • name: string
    • Optional defaultValue: unknown

    Returns any

parseOptions

  • parseOptions(options: CLIOption<any>[], args: string[]): {}
  • Process the raw CLI arguments using an array of option class instances to build a mapping of option names to provided values.

    Parameters

    Returns {}

    • [key: string]: any

Private setOptionValues

  • setOptionValues(optionValues: any): void

success

  • success(output: unknown): void
  • Print the given output to the log as success text.

    Parameters

    • output: unknown

    Returns void

Protected untilInterrupt

  • untilInterrupt(callback?: () => unknown): Promise<void>
  • Get a promise that resolves after SIGINT is received, executing a callback beforehand.

    Parameters

    • Optional callback: () => unknown
        • (): unknown
        • Returns unknown

    Returns Promise<void>

verbose

  • verbose(output: unknown): void
  • Print the given output to the log as verbose text.

    Parameters

    • output: unknown

    Returns void

warn

  • warn(output: unknown): void
  • Print the given output to the log as warning text.

    Parameters

    • output: unknown

    Returns void

Extollo Logo

extollo (v. latin) - to lift up, to elevate

Extollo is a free & libre application framework in TypeScript.