Adds one or more aliases to an option. Used to create short aliases such '-a', '-b' etc. Could be called multiple times, the alias lists will be concatenated.
alias list
Marks the option as multiple.
It allows to pass the same option multiple times.
So -o 1 -o 2 -o 3
will be resolved as [1, 2, 3]
.
Important: result will be an array even if only one value
was presented (or no value at all)
i.e. both []
and [1]
are valid results.
Sets the compliter for the option. A completer is a function to be called when shell completion is computated for an option. See 'oneOf' preset source code for usage.
completer function
Sets the default value for an option.
Option will be resolved to that value if no value was present.
Also removes nullability
from the result type like required()
does.
default value of the option
Sets the description of the option that is printed with the rest of the help when '--help' flag is provided.
description string
Allows to create custom type name.
Useful for presets, allows to get output like:
expected <MyType> but recieved <string>
new label for the type
Adds a pre-/post- processor. A processor is a function
that takes a value and return a new one. Each processor gets
the result from the previous one and passes new value to the next one.
So it looks like this: argv -> proc1 -> proc2 -> result data
Preprocessors run from raw input and before validation, while postprocessors run after validation and can produce either invalid or non-string-like values such as objects, functions etc.
So the full data pipeline looks like this:
argv -> preprocessors -> validators -> postprocessors -> result data
determine whether it will be a preprocessor or post processor
a processor function
Marks the option as required.
Required options must be provided. Otherwise
the program will quit with non-zero code and print an error.
On the other hand required options always accessible so
there is no need to check if they are presented i.e.
no options.foo && options.foo.toString()
checks.
Adds custom validation function.
error message to be shown if the result of validate function is falsy
a validate function that takes a value and return true
for valid
values and false
otherwise
Adds custom validation function.
a validate function that will throw an error if the provided value is invalid
Generated using TypeDoc
Option - is a helper class used to configure options. It's used for chained calls such as