tsargp
    Preparing search index...

    Type Alias OptionAttributes<P>

    Defines all option attributes.

    type OptionAttributes<P = any> = {
        append?: boolean;
        break?: boolean;
        choices?: ReadonlyArray<string>;
        cluster?: string;
        clusterPrefix?: string;
        complete?: CompletionCallback;
        default?: NonCallable | DefaultValueCallback;
        deprecated?: StyledString;
        example?: NonCallable;
        group?: string | null;
        inline?: InlineConstraint;
        layout?: HelpLayout;
        limit?: number;
        link?: URL;
        mapping?: Readonly<Record<string, unknown>>;
        marker?: string | [string, string];
        names?: ReadonlyArray<string | null>;
        normalize?: NormalizationCallback;
        optionPrefix?: string;
        options?: NestedOptions;
        paramCount?: number | NumericRange;
        paramName?: StyledString;
        parse?: ParsingCallback<P>;
        positional?: boolean;
        preferredName?: string;
        regex?: RegExp;
        required?: boolean;
        requiredIf?: Requires;
        requires?: Requires;
        saveMessage?: boolean;
        sections?: HelpSections;
        separator?: string | RegExp;
        skipCount?: number;
        sources?: ReadonlyArray<string | URL>;
        stdin?: boolean;
        styles?: OptionStyles;
        synopsis?: StyledString;
        unique?: boolean;
        usageParamName?: StyledString;
        useCommand?: boolean;
        useFilter?: boolean;
        version?: StyledString;
    }

    Type Parameters

    • P = any

      The type of parse parameter

    Index

    Properties

    append?: boolean

    Allows appending elements if supplied multiple times.

    false
    
    break?: boolean

    True to break the parsing loop after parsing the option.

    false
    
    choices?: ReadonlyArray<string>

    The allowed parameter values.

    cluster?: string

    The letters used for clustering in short-option style (e.g., 'fF').

    Letters are subject to the same restrictions as OptionAttributes.names.

    clusterPrefix?: string

    The prefix of cluster arguments. If set, then eligible arguments that have this prefix will be considered a cluster. Has precedence over OptionAttributes.optionPrefix.

    A custom callback for word completion.

    Te default value or a callback that returns the default value.

    The default value is set at the end of the parsing loop if the option was not supplied. You may use a callback to inspect parsed values and determine the default value based on those values.

    deprecated?: StyledString

    The option deprecation notice.

    example?: NonCallable

    The example value to display in the parameter column or in usage statements.

    group?: string | null

    The option group in the help message. Use the value null to hide it from the help message.

    Whether inline parameters should be disallowed or required for this option. Can be false to disallow or 'always' to always require.

    It can also be a record that maps option names to one of the above, indicating whether the corresponding name disallows or requires inline parameters.

    layout?: HelpLayout

    The option-specific layout settings.

    limit?: number

    The maximum allowed number of elements.

    Infinity
    
    link?: URL

    A hyperlink to an external resource.

    mapping?: Readonly<Record<string, unknown>>

    A record that maps parameter values to option values.

    marker?: string | [string, string]

    The marker(s) to delimit option parameters. If set, then all arguments appearing after/within the marker(s) will pertain to this option. It is subject to the same restrictions as OptionAttributes.names.

    names?: ReadonlyArray<string | null>

    The option names, as they appear on the command-line (e.g. -h or --help).

    Names cannot contain the equals sign =, since it may be used as option-parameter separator. nulls can be specified in order to skip the respective "slot" in the help message names column.

    A normalization function applied to parameters before they get validated and/or parsed.

    optionPrefix?: string

    The prefix of option names. If set, then arguments that have this prefix will always be considered an option name.

    options?: NestedOptions

    The subcommand's options. It can also be a module path or a callback that returns the options.

    paramCount?: number | NumericRange

    The function's parameter count:

    • If unspecified or Infinity, the option accepts unlimited parameters.
    • If zero, the option accepts unknown number of parameters (use with OptionAttributes.skipCount).
    • If positive, then the option expects exactly this number of parameters.
    • If a range, then the option expects between min and max parameters.
    Infinity
    
    paramName?: StyledString

    The parameter name to display in the parameter column or in usage statements. Overrides OptionAttributes.example in usage statements.

    A custom callback for parsing the option parameter(s).

    positional?: boolean

    Whether the option accepts positional arguments.

    If there are multiple positional options, their declaration order determines their relative position in the command line. A variadic option will take all remaining positional arguments. Otherwise, if there are more arguments than options, the last such option will take the excess.

    We recommend also setting OptionAttributes.preferredName to some explanatory name.

    false
    
    preferredName?: string

    A name to be displayed in error and help messages in cases where one is not available (e.g., when evaluating option requirements or processing positional arguments). It is not validated and can be anything.

    If not specified, the first name in the OptionAttributes.names array will be used.

    regex?: RegExp

    The regular expression that parameters should match.

    required?: boolean

    True if the option is always required.

    false
    
    requiredIf?: Requires

    The conditional requirements.

    requires?: Requires

    The forward requirements.

    saveMessage?: boolean

    Whether to save the message in the option value instead of throwing it.

    false
    
    sections?: HelpSections

    The help sections to be rendered.

    separator?: string | RegExp

    The parameter value separator.

    skipCount?: number

    The number of remaining arguments to skip. It is meant to be changed by the callback. (The parser does not alter this value.)

    0
    
    sources?: ReadonlyArray<string | URL>

    The names of data sources to try reading from (in that order), if the option was not supplied on the command line. A string means an environment variable, while a URL means a local file.

    Environment variable names are subject to the same restrictions as OptionAttributes.names.

    Has precedence over OptionAttributes.stdin.

    stdin?: boolean

    True to read data from the standard input, if the option was not supplied.

    Warning: this may block the application if OptionAttributes.required is set and the terminal is interactive.

    false
    
    styles?: OptionStyles

    The option display styles.

    synopsis?: StyledString

    The option synopsis.

    unique?: boolean

    True if duplicate elements should be removed.

    false
    
    usageParamName?: StyledString

    The parameter name to display in usage statements. Overrides OptionAttributes.example and OptionAttributes.paramName in usage statements.

    useCommand?: boolean

    Whether to use the next argument as the name of a subcommand. Has precedence over OptionAttributes.useFilter.

    false
    
    useFilter?: boolean

    Whether to use the remaining arguments as option filter.

    false
    
    version?: StyledString

    The version information (e.g., a semantic version).