Skip to content

ArgSchema ​

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

Signatures ​

ts
interface ArgSchema<K extends ArgKind> {}

Members ​

Properties ​

schemaBrand ​

Type-only seal produced by createArgSchema.

ts
schemaBrand: "arg";

completion ​

Callback used to complete this input's values.

ts
completion?: CompletionHandler | undefined;

kind ​

What kind of value this arg accepts.

ts
kind: K;

presence ​

Current presence state.

ts
presence: ArgPresence;

variadic ​

Whether this arg consumes all remaining positionals.

ts
variadic: boolean;

stdin ​

Stdin binding set by .stdin() (undefined when the arg never reads stdin). See StdinBinding.

ts
stdin: StdinBinding | undefined;

defaultValue ​

Runtime default value (if any).

ts
defaultValue: unknown;

defaultDescription ​

Human-readable replacement for the default value in help, or false to omit the default annotation.

ts
defaultDescription: string | false | undefined;

sensitive ​

Whether values from this input must be kept out of user-facing projections.

ts
sensitive: boolean;

description ​

Human-readable description for help text.

ts
description: HelpDescription | undefined;

group ​

Named section in command help.

ts
group: string | undefined;

envVar ​

Environment variable name for env resolution.

When set and the CLI value is absent, the resolver reads this env var and coerces the string to the arg's declared kind.

ts
envVar: string | undefined;

envIndexed ​

Indexed environment family read as the env source, set by .env() with an IndexedEnvBinding (undefined otherwise). An arg declares at most one env source, so this and ArgSchema.envVar are never both set.

ts
envIndexed: IndexedEnvBinding | undefined;

envAbsolute ​

Whether the env source is read exactly as written, outside the CLI-wide namespace set by CLIBuilder.envPrefix() (set by .env(…, { absolute: true })). Applies to ArgSchema.envVar and ArgSchema.envIndexed alike.

ts
envAbsolute: boolean;

envFromName ​

Whether .env() was called without a name. Registration on a command replaces it with the derived ArgSchema.envVar.

ts
envFromName: boolean;

configPath ​

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

ts
configPath: string | undefined;

prompt ​

Interactive prompt configuration.

ts
prompt: PromptConfig | undefined;

enumValues ​

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

ts
enumValues: readonly string[] | undefined;

elementSchema ​

Element schema when kind === 'keyValue'.

Describes the value of each entry, so arg.keyValue(arg.number()) decodes A=1 to the number 1. undefined leaves entry values as strings.

ts
elementSchema: ArgSchema | 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;

stringConstraints ​

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

Enforced at the parse and resolution boundaries, in fixed order: nonEmpty → minLength → maxLength → pattern. A defaultValue is a typed value, so it is validated against them when the schema is built.

ts
stringConstraints: StringConstraints | undefined;

pathChecks ​

Filesystem checks for path-valued args (set by arg.path()).

Validated after resolution through the runtime adapter, so CLI, stdin, env, and defaulted values are all checked. Only meaningful when kind === 'string'.

ts
pathChecks: PathChecks | undefined;

valueHint ​

Help placeholder label (e.g. 'url').

Set by the sugar factories (arg.url(), arg.date(), …) so tooling reading the schema knows the expected value shape. Help renders a positional by its own name, so this does not change the usage line.

ts
valueHint: string | undefined;

parseFn ​

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

ts
parseFn: ArgParseFn<unknown> | undefined;

separator ​

CLI value separator for a collection (undefined otherwise).

When set, each positional token is split on this separator before element coercion. Other sources decode through ArgSchema.split.

ts
separator: string | undefined;

split ​

Env and stdin split policies for a collection (undefined otherwise).

A source the binding leaves out takes its default: comma-delimited for env, line-delimited for stdin.

ts
split: SourceSplitBinding | undefined;

duplicateKeys ​

How a repeated key combines when kind === 'keyValue'.

ts
duplicateKeys: DuplicateKeys;

unique ​

Deduplicate the resolved values of a variadic arg.

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

ts
unique: boolean;

standard ​

Standard Schema v1 validator applied to each resolved value.

When set, the value from any source (CLI, env, stdin, default) is validated after resolution via ~standard.validate. Sync and async validators are both awaited; issues surface as a CONSTRAINT_VIOLATEDValidationError. A variadic arg validates every element with it.

ts
standard: StandardSchemaV1 | undefined;

aggregateStandard ​

Standard Schema v1 validator applied to the completed collection.

Set by .standard() on a builder that already aggregates, so the array or record is validated as a whole after every element passed.

ts
aggregateStandard: StandardSchemaV1 | undefined;

deprecated ​

Deprecation marker.

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

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

ts
deprecated: string | true | undefined;

See Also ​

Released under the MIT License.