Type Alias: CommonOptionConfig<T, TCoerce, TChoices>
CommonOptionConfig<
T
,TCoerce
,TChoices
>:object
Type Parameters
• T
• TCoerce = T
• TChoices = T
[]
Type declaration
alias?
optional
alias:string
[]
Provide an array of aliases for the option.
choices?
optional
choices:TChoices
| () =>TChoices
Provide an array of choices for the option. Values not in the array will throw an error.
coerce()?
optional
coerce: (value
) =>TCoerce
Provide a function to coerce the value of the option.
Parameters
• value: T
Value of the option
Returns
TCoerce
Coerced value of the option
default?
optional
default:Default
<T
>
Provide a default value for the option.
If the default value is a tuple, the first value will be used as the default value, and the second value will be used as the description.
deprecated?
optional
deprecated:string
If set, the option will be marked as deprecated, with the provided message. This will not effect runtime behavior, but will be displayed in help output and generated docs.
description?
optional
description:string
Provide a description for the option.
env?
optional
env:string
|boolean
|object
If set, the option will be populated from the environment variable ${env}_${optionName}
.
If set to true, the environment variable will be ${optionName}
.
If explicitly set to false, environment variable population will be disabled for this option.
group?
optional
group:string
Can be set to group options in help output and generated docs.
hidden?
optional
hidden:boolean
If true, the option will not be displayed in help output or generated docs.
positional?
optional
positional:boolean
If set to true, the option will be treated as a positional argument.
required?
optional
required:boolean
If true, the option is required.
validate()?
optional
validate: (value
) =>boolean
|string
Provide a function to validate the value of the option.
Parameters
• value: TCoerce
Coerced value of the option
Returns
boolean
| string
If the value is valid, return true. If the value is invalid, return false or a string with an error message.