Function: boolean()
Call Signature
export declare function boolean<const R extends boolean>(opts: BooleanOptions & {
required: R;
}): WithRequiredOption<CombinatorSchema<boolean>, R>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, or on an explicit =true / =false value. Other inline values are rejected before the parse function is called.
Type Parameters
| Name | Description |
|---|---|
R extends boolean | The type of required in the options, which the schema keeps. |
Parameters
| Name | Type | Description |
|---|---|---|
opts | BooleanOptions & { required: R } | Boolean options. |
Returns
WithRequiredOption<CombinatorSchema<boolean>, R> — A combinator schema for boolean flags.
Examples
const args = {
color: boolean({ negatable: true })
}
// Usage: --color (true), --no-color (false)Call Signature
export declare function boolean<const R extends boolean | undefined = boolean | undefined>(opts?: BooleanOptions & {
required?: R;
}): WithUnrequiredOption<CombinatorSchema<boolean>, R>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, or on an explicit =true / =false value. Other inline values are rejected before the parse function is called.
Type Parameters
| Name | Description |
|---|---|
R extends boolean | undefined = boolean | undefined | The type of required in the options, which the schema keeps when it may be false but not true, as for optional ? { required: false } : {}, so that a positional argument with it is optional. |
Parameters
| Name | Type | Description |
|---|---|---|
opts | BooleanOptions & { required?: R } | Boolean options. (optional) |
Returns
WithUnrequiredOption<CombinatorSchema<boolean>, R> — A combinator schema for boolean flags.
Examples
const args = {
color: boolean({ negatable: true })
}
// Usage: --color (true), --no-color (false)Call Signature
export declare function boolean(opts?: BooleanOptions): CombinatorSchema<boolean>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, or on an explicit =true / =false value. Other inline values are rejected before the parse function is called.
Parameters
| Name | Type | Description |
|---|---|---|
opts | BooleanOptions | Boolean options. (optional) |
Returns
CombinatorSchema<boolean> — A combinator schema for boolean flags.
Examples
const args = {
color: boolean({ negatable: true })
}
// Usage: --color (true), --no-color (false)