Skip to content

gunshi / combinators / short

Function: short()

ts
function short<T, S>(schema, alias): ArgSchema & Combinator<T> & CombinatorShort<S>;

Experimental

Set a short alias on a combinator schema.

The original schema is not modified.

Type Parameters

Type ParameterDescription
TThe schema's parsed type.
S extends stringThe short alias string literal type.

Parameters

ParameterTypeDescription
schemaCombinatorSchema<T>The base combinator schema.
aliasSSingle character short alias.

Returns

ArgSchema & Combinator<T> & CombinatorShort<S>

A new schema with the short alias set.

Example

ts
const args = {
  verbose: short(boolean(), 'v')
}
// Usage: -v or --verbose

Released under the MIT License.