Function: positional()
Call Signature
ts
declare function positional<T>(parser: CombinatorSchema<T>): CombinatorSchema<T> & ArgSchemaPositionalTypeWARNING
This API is experimental and may change in future versions.
Create a positional argument schema.
Without a parser, resolves to string. With a parser (e.g., positional(integer())), resolves to the parser's return type.
Type Parameters
| Name | Description |
|---|---|
T | The parser's resolved type. |
Parameters
| Name | Type | Description |
|---|---|---|
parser | CombinatorSchema<T> | The parser combinator schema. |
Returns
CombinatorSchema<T> & ArgSchemaPositionalType — A positional argument schema resolving to the parser's type.
Examples
ts
const args = {
command: positional(), // resolves to string
port: positional(integer()), // resolves to number
}Call Signature
ts
declare function positional(parser?: BaseOptions): ArgSchema & ArgSchemaPositionalTypeWARNING
This API is experimental and may change in future versions.
Create a positional argument schema.
Without a parser, resolves to string. With a parser (e.g., positional(integer())), resolves to the parser's return type.
Parameters
| Name | Type | Description |
|---|---|---|
parser | BaseOptions | Optional base options (description, short, required). (optional) |
Returns
ArgSchema & ArgSchemaPositionalType — A positional argument schema resolving to string.
Examples
ts
const args = {
command: positional(), // resolves to string
port: positional(integer()), // resolves to number
}