Skip to content

FlagSchema

The runtime descriptor stored inside every FlagBuilder. Consumers (parser, help generator, resolution chain) read this to understand the flag's shape without touching generics.

Signatures

ts
interface FlagSchema {}

Members

Properties

aliases

Short/long aliases (e.g. [{ name: 'f', hidden: false }] for --force).

ts
aliases: readonly FlagAlias[];

configPath

Dotted config path for v0.2+ resolution (e.g. 'deploy.region').

ts
configPath: string | undefined;

defaultValue

Runtime default value (if any).

ts
defaultValue: unknown;

deprecated

Deprecation marker.

  • undefined — not deprecated (default)
  • true — deprecated with no migration message
  • string — deprecated with a reason/migration message

When a deprecated flag is used, a warning is emitted to stderr. Help text shows [deprecated] or [deprecated: <reason>].

ts
deprecated: string | true | undefined;

description

Human-readable description for help text.

ts
description: string | undefined;

duplicates

Duplicate policy for repeated CLI occurrences. See DuplicatePolicy.

ts
duplicates: DuplicatePolicy;

elementSchema

Element schema when kind === 'array'.

ts
elementSchema: FlagSchema | undefined;

enumValues

Allowed literal values when kind === 'enum'.

ts
enumValues: readonly string[] | undefined;

envVar

Environment variable name for v0.2+ resolution.

ts
envVar: string | undefined;

kind

What kind of value this flag accepts.

ts
kind: "string" | "number" | "boolean" | "enum" | "array" | "custom" | "count" | "keyValue";

negation

Negation settings when kind === 'boolean' and .negatable() was called (undefined otherwise). See FlagNegation.

ts
negation: FlagNegation | undefined;

numberConstraints

Numeric constraints when kind === 'number' (undefined otherwise).

Enforced at the parse and resolution boundaries. finite defaults to true, so Infinity is rejected even when no constraints object is set.

ts
numberConstraints: NumberConstraints | undefined;

parseFn

Custom parse function (only when kind === 'custom').

ts
parseFn: FlagParseFn<unknown> | undefined;

pathChecks

Filesystem checks for path-valued flags (set by flag.path()).

Validated after resolution through the runtime adapter.

ts
pathChecks: PathChecks | undefined;

presence

Current presence state.

ts
presence: "optional" | "required" | "defaulted";

prompt

Interactive prompt configuration for v0.3+ resolution.

ts
prompt: PromptConfig | undefined;

propagate

Whether this flag propagates to subcommands in nested command trees.

When true, the flag is automatically available to all descendant commands. A child command that defines a flag with the same name shadows the propagated parent flag.

ts
propagate: boolean;

separator

Value separator when kind === 'array' (undefined otherwise).

When set, each CLI occurrence is split on this separator before element coercion, so --tag a,b --tag c yields ['a', 'b', 'c']. Env and config string values use this separator too (default ',').

ts
separator: string | undefined;

standard

Standard Schema v1 validator applied to the resolved value.

When set, the value from any source (CLI, env, config, prompt, default) is validated after resolution via ~standard.validate. Sync and async validators are both awaited; issues surface as a CONSTRAINT_VIOLATED ValidationError. Only meaningful when kind === 'custom'.

ts
standard: StandardSchemaV1<unknown, unknown> | undefined;

stringConstraints

String constraints when kind === 'string' (undefined otherwise).

Enforced at the parse and resolution boundaries, in fixed order: nonEmpty → minLength → maxLength → pattern.

ts
stringConstraints: StringConstraints | undefined;

unique

Deduplicate resolved array values when kind === 'array'.

Applied after all sources resolve, preserving first-seen order. Uses SameValueZero semantics (like Set).

ts
unique: boolean;

valueHint

Help placeholder label (e.g. 'url' renders as <url>).

Set by the sugar factories (flag.url(), flag.date(), …) so help output names the expected value shape; undefined falls back to the kind-derived hint.

ts
valueHint: string | undefined;

See Also

Released under the MIT License.