CliArgs
Extends:
command-line arguments reader.
This reader is used by the Cli handler. It supports most of
the docopt specification. Also, if the reader finds an error it's capable of
reporting it in user-friendly way. This is used to report -h/--help
and
missing arguments.
All serializable inputs are supported by this handler, they can be displayed
either as argument
or option
element. This is done by setting the input
property elementType
(option is the default one).
You can define the description displayed in the help of each input by
setting the input's property description
. Also, the description for the action
itself can be defined by setting the action's metadata description
.
The option
elements support short option
by setting the input property
shortOption
.
In order to accommodate how vector values are represented in a command-line interface, this reader expects vector elements to be separated by the space character.
Any Bool input specified as an option
element behaves in a
special mode, since it's treated as a toogle option in command-line.
Therefore if the Bool input is assigned with a true
then the option
gets the prefix no-
.
When a value is found for the input, it gets loaded via Input.parseValue where each input implementation has its own way of parsing the serialized data, to find out about how a value is serialized for an specific input type you could simply set an arbitrary value to the input you are interested then query it back through Input.serializeValue. Also, Mebo provides a reference datasheet about the serialization forms for the inputs bundled with it, found at Reader.
Constructor Summary
Public Constructor | ||
public |
constructor(action: Action, argv: Array<string>) Creates an args reader |
Method Summary
Public Methods | ||
public |
Returns a list of args used by the reader, by default it uses
|
|
public |
executableName(placeHolder: string): string Returns the executable name based on the args |
Protected Methods | ||
protected |
Implements the reader |
|
protected |
_renderHelp(elements: Object): Promise<string> Computes the contents displayed as help |
Inherited Summary
From class Reader | ||
public |
Returns the action associated with the reader. |
|
public |
async autofillValues(): Promise<Object> Reads the autofill information and returns it through a plain object. |
|
public |
async inputValues(): Promise<object> Reads the input values and returns it through a plain object. |
|
public |
Returns an option |
|
public |
Sets a value under the options |
|
public |
Returns a list of valid input names that should be used for the parsing. |
|
protected |
This method should be re-implemented by derived classes to perform the handler parsing. |
Public Constructors
Public Methods
public args(): Array<string> source
Returns a list of args used by the reader, by default it uses
process.argv
.
public executableName(placeHolder: string): string source
Returns the executable name based on the args
Params:
Name | Type | Attribute | Description |
placeHolder | string | when placeHolder is enabled it returns an uuid string that can be used later to replace for the real executable name returned by default |