Skip to content

gunshi / combinators / boolean

Function: boolean()

ts
function boolean(opts?): CombinatorSchema<boolean>;

Experimental

Create a boolean argument schema.

Boolean arguments are existence-based. The resolver passes "true" or "false" to the parse function based on the presence or negation of the flag.

Parameters

ParameterTypeDescription
opts?BooleanOptionsBoolean options.

Returns

CombinatorSchema<boolean>

A combinator schema for boolean flags.

Example

ts
const args = {
  color: boolean({ negatable: true })
}
// Usage: --color (true), --no-color (false)

Released under the MIT License.