Skip to content

@clerc/parser

Classes

ClassDescription

InvalidSchemaError

Interfaces

InterfaceDescription

FlagDefaultValueFunction

ObjectInputType

ParsedResult

The parsed result.

ParserOptions

Configuration options for the parser.

TypeFunction

Defines how a string input is converted to the target type T.

Type Aliases

Type AliasDescription

BaseFlagOptions

FlagDefaultValue

FlagDefinitionValue

FlagOptions

FlagsDefinition

IgnoreFunction

A callback function to conditionally stop parsing. When it returns true, parsing stops and remaining arguments are preserved in ignored.

InferFlags

An advanced utility type that infers the exact type of the flags object in the parsed result, based on the provided flags configuration object T.

RawInputType

TypeValue

Variables

VariableDescription

DOUBLE_DASH

KNOWN_FLAG

PARAMETER

UNKNOWN_FLAG

Functions

FunctionDescription

appendDotValues

Similar to setDotValues but handles duplicate keys by converting to arrays. Does NOT apply type conversion - value is set as-is. Useful for flags that can be specified multiple times.

coerceObjectValue

Default value coercion for Object type. Converts "true" / "" to true, "false" to false, other values remain unchanged.

createParser

inferDefault

Infers the implicit default value for a flag type based on its type constructor. This is useful for help output to show the default values of types that have built-in defaults.

  • Boolean: false
  • [Boolean] (Counter): 0
  • [T] (Array): []
  • Object: {}
  • Others: undefined (no implicit default)

parse

setDotValues

Sets a value at a nested path in an object, creating intermediate objects as needed. Does NOT apply type conversion - value is set as-is. Overwrites existing values.

在 MIT 许可证下发布