Interface JackOptions

Options provided to the Jack constructor

interface JackOptions {
    allowPositionals?: boolean;
    env?: Record<string, undefined | string>;
    envPrefix?: string;
    stopAtPositional?: boolean;
    stopAtPositionalTest?: ((arg: string) => boolean);
    usage?: string;
}

Properties

allowPositionals?: boolean

Whether to allow positional arguments

true
env?: Record<string, undefined | string>

Environment object to read/write. Defaults process.env. No effect if envPrefix is not set.

envPrefix?: string

Prefix to use when reading/writing the environment variables

If not specified, environment behavior will not be available.

stopAtPositional?: boolean

Stop parsing flags and opts at the first positional argument. This is to support cases like cmd [flags] <subcmd> [options], where each subcommand may have different options. This effectively treats any positional as a -- argument. Only relevant if allowPositionals is true.

To do subcommands, set this option, look at the first positional, and parse the remaining positionals as appropriate.

false
stopAtPositionalTest?: ((arg: string) => boolean)

Conditional stopAtPositional. If set to a (string)=>boolean function, will be called with each positional argument encountered. If the function returns true, then parsing will stop at that point.

usage?: string

A short usage string. If not provided, will be generated from the options provided, but that can of course be rather verbose if there are a lot of options.