Skip to content

Option

One entry in a command's options record. The key is the option name.

Property Type Description
schema Schema Validates the value, and decides whether the option 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.
aliases? string[] Extra names, written as JavaScript identifiers, so i becomes -i and listName becomes --list-name.
exclusive? boolean The option must appear on its own, apart from anything listed in requires.
requires? string[] Names that must also be provided when this option is used. Names, not aliases.
conflictWith? string[] Names that cannot be provided together with this option.
meta? OptionMeta Text used by help output and generated docs. Never changes behavior.

Constraints only look at what the user actually provided. They ignore a value that is present because of a schema default. See Constraints.

The coerce helper that you pick also decides how the flag behaves. Boolean flags, repeatable options, and object options all come from it. See Coerce helpers.

OptionMeta

Property Type Description
placeholder? string Shown after the flag to hint at the expected value, for example <path>.
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 option optional or required in help and docs only.
hidden? boolean Leave the option out of help and docs.