Module: option
Classes
Type Aliases
OptionConfig
Ƭ OptionConfig<T, Args>: Object
Type parameters
| Name | Type |
|---|---|
T | unknown |
Args | extends ArgsObject = ArgsObject |
Type declaration
| Name | Type | Description |
|---|---|---|
name | string | Name of the option |
description | string | Description of the option, displayed in the help output |
aliases | string[] | Aliases for the option, which can be used with the shorthand option notation. |
defaultValue? | any | Default value of the option |
array? | boolean | Whether the option is an array. Array options can be specified multiple times, and the values will be collected into an array. Normally, specifying an option multiple times will override the previous value. |
required? | boolean | Whether the option is required. If it is required, parsing will throw an error if it's not present. |
isDefault? | boolean | Whether the option is the default option. The default option is the option that is used if no other option is specified, e.g. a value is passed in without an option name. Note that if commands match the same argument first, they will be used instead of the default option. |
hidden? | boolean | Whether the option is hidden. Hidden options are not displayed in the help output. |
outputName? | string | Specify a custom name for the output, which will be used when parsing the args. |
parse? | Parser<Args, T> | Parse the value of the option. You can return any type here, or throw an error if the value is invalid. |
Defined in
FlagConfig
Ƭ FlagConfig: Object
Type declaration
| Name | Type |
|---|---|
name | string |
description | string |
aliases | string[] |
defaultValue | any |
array | undefined | boolean |
required | undefined | boolean |
hidden | undefined | boolean |
outputName | undefined | string |
negatable | undefined | boolean |
negationName | undefined | string |
negationAliases | undefined | string[] |
Defined in
Parser
Ƭ Parser<Args, OptionType>: (x: string, y: Args) => OptionType
A function that parses an option value.
Type parameters
| Name | Type |
|---|---|
Args | extends ArgsObject = ArgsObject |
OptionType | extends any = any |
Type declaration
▸ (x, y): OptionType
Parameters
| Name | Type |
|---|---|
x | string |
y | Args |
Returns
OptionType
Defined in
TypedOptionConfig
Ƭ TypedOptionConfig<T, A>: Object
Type parameters
| Name | Type |
|---|---|
T | T |
A | extends ArgsObject = ArgsObject |
Type declaration
| Name | Type |
|---|---|
name | string |
description | string |
aliases | string[] |
type | undefined | "number" |
defaultValue | any |
array | undefined | boolean |
required | undefined | boolean |
isDefault | undefined | boolean |
hidden | undefined | boolean |
outputName | undefined | string |
parse | undefined | Parser<A, T> |
Defined in
ArrayOptionConfig
Ƭ ArrayOptionConfig<T>: Object
An option that can be passed to a command.
This type represents an array option, which can be specified multiple times.
Type parameters
| Name | Type |
|---|---|
T | unknown |
Type declaration
| Name | Type |
|---|---|
name | string |
description | string |
aliases | string[] |
type | undefined | "number" |
defaultValue | undefined | ZodType<T, ZodTypeDef, T>[] |
array | undefined | boolean |
required | undefined | boolean |
isDefault | undefined | boolean |
hidden | undefined | boolean |
outputName | undefined | string |
parse | undefined | Parser<ArgsObject, ZodType<T, ZodTypeDef, T>[]> |
Defined in
Prefixes
Ƭ Prefixes: Object
Type declaration
| Name | Type |
|---|---|
normalPrefix | string |
aliasPrefix | string |
Defined in
Names
Ƭ Names: Object
Type declaration
| Name | Type |
|---|---|
name | string |
aliases | string[] |
Defined in
QualifiedNames
Ƭ QualifiedNames: Object
Names with prefixes built-in
Type declaration
| Name | Type |
|---|---|
name | string |
aliases | string[] |
negationName | string |
negationAliases | string[] |
Defined in
Variables
FlagConfig
• Const FlagConfig: ZodObject<FlagConfig>
Configuration for a flag (boolean argument) that can be passed to a command.
Defined in
DEFAULT_OPT_FULL_PREFIX
• Const DEFAULT_OPT_FULL_PREFIX: "--"
The default prefixes for options
Defined in
DEFAULT_OPT_SHORT_PREFIX
• Const DEFAULT_OPT_SHORT_PREFIX: "-"
The default prefix for option aliases
Defined in
Functions
OptionConfig
▸ OptionConfig<OptionType, Args>(type): ZodObject<{ name: ZodString ; description: ZodString ; defaultValue: ZodOptional<ZodAny> ; aliases: ZodArray<ZodString, "many"> ; parse: ZodOptional<ZodType<Parser<Args, OptionType>, ZodTypeDef, Parser<Args, OptionType>>> ; array: ZodOptional<ZodBoolean> ; required: ZodOptional<ZodBoolean> ; isDefault: ZodOptional<ZodBoolean> ; hidden: ZodOptional<ZodBoolean> ; outputName: ZodOptional<ZodString> }, "strip", ZodTypeAny, { name: string ; description: string ; aliases: string[] ; defaultValue?: any ; array?: boolean ; required?: boolean ; isDefault?: boolean ; hidden?: boolean ; outputName?: string ; parse?: Parser<Args, OptionType> }, { name: string ; description: string ; aliases: string[] ; defaultValue?: any ; array?: boolean ; required?: boolean ; isDefault?: boolean ; hidden?: boolean ; outputName?: string ; parse?: Parser<Args, OptionType> }>
Type parameters
| Name | Type |
|---|---|
OptionType | OptionType |
Args | extends ArgsObject = ArgsObject |
Parameters
| Name | Type |
|---|---|
type | ZodType<OptionType, ZodTypeDef, OptionType> |
Returns
ZodObject<{ name: ZodString ; description: ZodString ; defaultValue: ZodOptional<ZodAny> ; aliases: ZodArray<ZodString, "many"> ; parse: ZodOptional<ZodType<Parser<Args, OptionType>, ZodTypeDef, Parser<Args, OptionType>>> ; array: ZodOptional<ZodBoolean> ; required: ZodOptional<ZodBoolean> ; isDefault: ZodOptional<ZodBoolean> ; hidden: ZodOptional<ZodBoolean> ; outputName: ZodOptional<ZodString> }, "strip", ZodTypeAny, { name: string ; description: string ; aliases: string[] ; defaultValue?: any ; array?: boolean ; required?: boolean ; isDefault?: boolean ; hidden?: boolean ; outputName?: string ; parse?: Parser<Args, OptionType> }, { name: string ; description: string ; aliases: string[] ; defaultValue?: any ; array?: boolean ; required?: boolean ; isDefault?: boolean ; hidden?: boolean ; outputName?: string ; parse?: Parser<Args, OptionType> }>
Defined in
TypedOptionConfig
▸ TypedOptionConfig<OptionType, Args>(type): ZodObject<extendShape<{ name: ZodString ; description: ZodString ; defaultValue: ZodOptional<ZodAny> ; aliases: ZodArray<ZodString, "many"> ; parse: ZodOptional<ZodType<Parser<Args, OptionType>, ZodTypeDef, Parser<Args, OptionType>>> ; array: ZodOptional<ZodBoolean> ; required: ZodOptional<ZodBoolean> ; isDefault: ZodOptional<ZodBoolean> ; hidden: ZodOptional<ZodBoolean> ; outputName: ZodOptional<ZodString> }, { type: ZodOptional<ZodEnum<["number"]>> }>, "strip", ZodTypeAny, { name: string ; description: string ; aliases: string[] ; type: undefined | "number" ; defaultValue: any ; array: undefined | boolean ; required: undefined | boolean ; isDefault: undefined | boolean ; hidden: undefined | boolean ; outputName: undefined | string ; parse: undefined | Parser<Args, OptionType> }, { name: string ; description: string ; aliases: string[] ; type: undefined | "number" ; defaultValue: any ; array: undefined | boolean ; required: undefined | boolean ; isDefault: undefined | boolean ; hidden: undefined | boolean ; outputName: undefined | string ; parse: undefined | Parser<Args, OptionType> }>
OptionConfig with a specified value type
Type parameters
| Name | Type |
|---|---|
OptionType | OptionType |
Args | extends ArgsObject = ArgsObject |
Parameters
| Name | Type |
|---|---|
type | ZodType<OptionType, ZodTypeDef, OptionType> |
Returns
ZodObject<extendShape<{ name: ZodString ; description: ZodString ; defaultValue: ZodOptional<ZodAny> ; aliases: ZodArray<ZodString, "many"> ; parse: ZodOptional<ZodType<Parser<Args, OptionType>, ZodTypeDef, Parser<Args, OptionType>>> ; array: ZodOptional<ZodBoolean> ; required: ZodOptional<ZodBoolean> ; isDefault: ZodOptional<ZodBoolean> ; hidden: ZodOptional<ZodBoolean> ; outputName: ZodOptional<ZodString> }, { type: ZodOptional<ZodEnum<["number"]>> }>, "strip", ZodTypeAny, { name: string ; description: string ; aliases: string[] ; type: undefined | "number" ; defaultValue: any ; array: undefined | boolean ; required: undefined | boolean ; isDefault: undefined | boolean ; hidden: undefined | boolean ; outputName: undefined | string ; parse: undefined | Parser<Args, OptionType> }, { name: string ; description: string ; aliases: string[] ; type: undefined | "number" ; defaultValue: any ; array: undefined | boolean ; required: undefined | boolean ; isDefault: undefined | boolean ; hidden: undefined | boolean ; outputName: undefined | string ; parse: undefined | Parser<Args, OptionType> }>
Defined in
ArrayOptionConfig
▸ ArrayOptionConfig<T, A>(type): ZodObject<extendShape<extendShape<{ name: ZodString ; description: ZodString ; defaultValue: ZodOptional<ZodAny> ; aliases: ZodArray<ZodString, "many"> ; parse: ZodOptional<ZodType<Parser<A, T[]>, ZodTypeDef, Parser<A, T[]>>> ; array: ZodOptional<ZodBoolean> ; required: ZodOptional<ZodBoolean> ; isDefault: ZodOptional<ZodBoolean> ; hidden: ZodOptional<ZodBoolean> ; outputName: ZodOptional<ZodString> }, { type: ZodOptional<ZodEnum<["number"]>> }>, { defaultValue: ZodOptional<ZodArray<ZodType<T, ZodTypeDef, T>, "many">> }>, "strip", ZodTypeAny, { name: string ; description: string ; aliases: string[] ; type: undefined | "number" ; defaultValue: undefined | T[] ; array: undefined | boolean ; required: undefined | boolean ; isDefault: undefined | boolean ; hidden: undefined | boolean ; outputName: undefined | string ; parse: undefined | Parser<A, T[]> }, { name: string ; description: string ; aliases: string[] ; type: undefined | "number" ; defaultValue: undefined | T[] ; array: undefined | boolean ; required: undefined | boolean ; isDefault: undefined | boolean ; hidden: undefined | boolean ; outputName: undefined | string ; parse: undefined | Parser<A, T[]> }>
Type parameters
| Name | Type |
|---|---|
T | T |
A | extends ArgsObject = ArgsObject |
Parameters
| Name | Type |
|---|---|
type | ZodType<T, ZodTypeDef, T> |
Returns
ZodObject<extendShape<extendShape<{ name: ZodString ; description: ZodString ; defaultValue: ZodOptional<ZodAny> ; aliases: ZodArray<ZodString, "many"> ; parse: ZodOptional<ZodType<Parser<A, T[]>, ZodTypeDef, Parser<A, T[]>>> ; array: ZodOptional<ZodBoolean> ; required: ZodOptional<ZodBoolean> ; isDefault: ZodOptional<ZodBoolean> ; hidden: ZodOptional<ZodBoolean> ; outputName: ZodOptional<ZodString> }, { type: ZodOptional<ZodEnum<["number"]>> }>, { defaultValue: ZodOptional<ZodArray<ZodType<T, ZodTypeDef, T>, "many">> }>, "strip", ZodTypeAny, { name: string ; description: string ; aliases: string[] ; type: undefined | "number" ; defaultValue: undefined | T[] ; array: undefined | boolean ; required: undefined | boolean ; isDefault: undefined | boolean ; hidden: undefined | boolean ; outputName: undefined | string ; parse: undefined | Parser<A, T[]> }, { name: string ; description: string ; aliases: string[] ; type: undefined | "number" ; defaultValue: undefined | T[] ; array: undefined | boolean ; required: undefined | boolean ; isDefault: undefined | boolean ; hidden: undefined | boolean ; outputName: undefined | string ; parse: undefined | Parser<A, T[]> }>
See
- OptionConfig
- ArrayOptionConfig