Readonly
argAn index of the first command line argument the reader should recognized.
Readonly
argsCommand line arguments the option is read from.
These arguments may be updated by option syntax between the read attempts.
Readonly
keyOption key used to find corresponding option readers.
This may be the same as [name], or may be e.g. a wildcard key when no readers for the option name recognized it. In any case, the option key is syntax-specific.
Readonly
nameOption name.
This is a command line argument at currently processed index.
Defers the option processing until recognized by another reader available for the same option key.
Calling this method marks arguments as unrecognized. This can be changed by calling any recognition method again. The already registered callback will be unregistered on such call.
Builds option location within parsed command line.
Optional
init: InitInitial properties of option location.
Option location within parsed command line arguments.
Marks current option as recognized.
This method is called by [rest] and [values].
This method can be called multiple times to register multiple actions to call. These actions won't be called once the option is marked as unrecognized again.
Optional
action: ((this) => void)The action to perform when the option recognized and all readers processed.
Reads up to the maximum number of the remaining command line arguments and treat them as option values.
Reads [values] and all command line arguments following them up to the end of command line or their maximum number.
Calling this method marks all arguments read as recognized. This can be undone by calling any recognition method again.
When called on already recognized option this method just returns the values previously returned to the reader that recognized them.
Optional
max: numberThe maximum number of arguments to read.
Command line arguments array.
Marks current option as unrecognized.
This method is called by [defer].
When calling without parameter the previous reason is not updated.
Does nothing if current option is recognized by another reader.
Optional
reason: unknownAn error to throw when all readers processed and option is still unrecognized. When omitted, the ZOptionError will be thrown.
Reads up to the maximum number of values of the option.
Values are command line options following the currently processed one. Their number depend on the
option syntax. E.g. a --name=value
syntax supports one value, while
--name value1 value2 ...
syntax supports any number of them.
Calling this method marks the option and value arguments as recognized. This can be undone by calling any recognition method again.
When called on already recognized option this method just returns the values previously returned to the reader that recognized them.
Optional
max: numberThe maximum number of values to read.
Option values array.
Allows to await for option recognition.
Calling this method does not alter option recognition status in any way, unlike recognition. An unlike deferring, the callback registered by this method will be called when the option recognized by any reader, not just the readers registered for the same option key.
Callback function that will be called when the option recognized and all readers processed.
Generated using TypeDoc
Base representation of command line option passed to its reader in order to be recognized.
A class implementing this interface along with any interface specific to the parser is created by ZOptionsParser.Config.optionClass method.
The reader uses option methods to recognize and consume command line arguments. Once recognized these arguments are consumed, and option reading continues from the next non-consumed argument.
If multiple readers correspond to the same option key, they all consulted in order. Once one of them recognized the option, the remaining and deferred ones receive an option instance representing already consumed option. The latter can be read by readers, but can no longer be updated.