Skip to content

Argument

One entry in a command's arguments record. The key is the argument name, and the order of the entries is the order they are read from the command line.

Property Type Description
schema Schema Validates the value, and decides whether the argument is required and what it defaults to. Required.
coerce? CoerceMethod<...> Converts the terminal string into the type the schema expects. Not needed when that type is string.
exclusive? boolean The argument must appear on its own, apart from anything listed in requires.
requires? string[] Names that must also be provided when this argument is used. Names, not aliases.
conflictWith? string[] Names that cannot be provided together with this argument.
meta? ArgumentMeta Text used by help output and generated docs. Never changes behavior.

Arguments have no aliases, since they are matched by position rather than by name.

The definition check enforces two rules. With allowPositionals: true no argument may be optional, and with allowPositionals: false only the last one may be. Argument names also cannot be numeric. See Typed arguments.

ArgumentMeta

Property Type Description
name? string Overrides the name shown in help and docs. Otherwise the key is shown in kebab-case.
description? string Plain text. Supports multiple lines and ANSI colors. Preferred in terminal help.
descriptionMarkdown? string Markdown. Preferred in generated Markdown, and formatted when printed to a terminal.
example? string Shown under the description in help, inside a code block in Markdown.
default? string Default shown in help and docs. Does not change the real default. Empty string shows none.
optional? boolean Marks the argument optional or required in help and docs only.
hidden? boolean Leave the argument out of help and docs.