Class Jack<C>

Class returned by the jack function and all configuration definition methods. This is what gets chained together.

Type Parameters

Hierarchy

  • Jack

Constructors

Properties

#allowPositionals: boolean
#configSet: C
#env: {
    [k: string]: string | undefined;
}

Type declaration

  • [k: string]: string | undefined
#envPrefix?: string
#fields: UsageField[] = []
#options: JackOptions
#shorts: {
    [k: string]: string;
}

Type declaration

  • [k: string]: string
#usage?: string
#usageMarkdown?: string

Methods

  • do not set fields as 'no-foo' if 'foo' exists and both are bools just set foo.

    Parameters

    • f: string
    • val: any
    • s: string = f

    Returns void

  • Parameters

    • start: number

    Returns {
        maxWidth: number;
        rows: (Row | TextRow)[];
    }

  • Parameters

    • name: string
    • field: {
          short?: string;
      }
      • Optional short?: string

    Returns void

  • Custom printer for util.inspect

    Parameters

    • _: number
    • options: InspectOptions

    Returns string

  • Generic field definition method. Similar to flag/flagList/number/etc, but you must specify the type (and optionally multiple and delim) fields on each one, or Jack won't know how to define them.

    Type Parameters

    Parameters

    • fields: F

    Returns Jack<C & F>

  • Add a long-form description to the usage output at this position.

    Parameters

    • text: string
    • __namedParameters: {
          pre?: boolean;
      } = {}
      • Optional pre?: boolean

    Returns Jack<C>

  • Add a heading to the usage output banner

    Parameters

    • text: string
    • Optional level: 1 | 2 | 3 | 4 | 5 | 6
    • __namedParameters: {
          pre?: boolean;
      } = {}
      • Optional pre?: boolean

    Returns Jack<C>

  • Parse a string of arguments, and return the resulting { values, positionals } object.

    If an JackOptions#envPrefix is set, then it will read default values from the environment, and write the resulting values back to the environment as well.

    Environment values always take precedence over any other value, except an explicit CLI setting.

    Parameters

    • args: string[] = process.argv

    Returns Parsed<C>

  • Set the default value (which will still be overridden by env or cli) as if from a parsed config file. The optional source param, if provided, will be included in error messages if a value is invalid or unknown.

    Parameters

    Returns Jack<C>

  • Return the configuration options as a plain object

    Returns {
        [k: string]: T;
    }

    • [k: string]: T
  • Return the usage banner for the given configuration

    Returns string

  • Return the usage banner markdown for the given configuration

    Returns string

  • Validate that any arbitrary object is a valid configuration values object. Useful when loading config files or other sources.

    Parameters

    • o: any

    Returns asserts o is OptionsResults<C>

Generated using TypeDoc