You can see below the API reference of this module.
The TildaOption
class used for creating option objects.
- Object
input
: An object containing the following fields: name
(String): The option name (optional).description
(String): The option description.opts
(Array): An array of aliases (e.g.["age", "a"]
).default
(Anything): The default value.handler
(Function): The option handler which will be called when the option is found in the arguments. The first parameter is the option object and the second argument is the action where the option belongs to.required
(Boolean): A flag representing if the option is mandatory or not (default:false
).type
(Class|String): The type class (e.g.String
) or its stringified representation (e.g."string"
).prompt
(Boolean|Object): Iffalse
, it will disable the prompt even if the option is required. If it's an object, it will passed as options toprompt-sync
.
- TildaOption The
TildaOption
instance. description
(String): The option description.opts
(Array): An array of aliases (e.g.["age", "a"]
).aliases
(Array): An array of strings containing the computed aliases, the single letter ones being the first (e.g.["-n", "--name"]
).value
(null|String|DefaultValue): The option value which was found after processing the arguments.def
(Anything): The provided default value.is_provided
(Boolean): A flag if the option was or not been provided.handler
(Function): The handler function.required
(Boolean): The required value.type
(Class|String): The option value type.prompt
(Boolean|Object): The prompt settings..
The TildaAction
class used for creating action objects.
This is extended EventEmitter
.
-
String|Object
info
: The path to a containing the needed information or an object containing: -
description|desc
(String): The action description. -
name
(String): The action name. -
bin
(Object): Apackage.json
-likebin
field (optional). -
args
(Array): An array of strings/objects representing the action argument names (default:[]
). -
examples
(Array): An array of strings containing examples how to use the action. -
notes
(String): Additional notes to display in the help command. -
documentation
(String): Action-related documentation. -
Object
options
: An object containing the following fields (if provided, they have priority over theinfo
object): -
args
(Array): An array of strings/objects representing the action argument names (default:[]
). -
examples
(Array): An array of strings containing examples how to use the action. -
notes
(String): Additional notes to display in the help command. -
documentation
(String): Action-related documentation.
- TildaAction The
TildaAction
instance containing: options
(Object): The action options.description
(String): The action description.name
(String): The action name.uniqueOpts
(Array): An array of unique options in order._args
(Array): The action arguments.argNames
(Array): The action argument names.args
(Object): The arguments' values.examples
(Array): An array of strings containing examples how to use the action.notes
(String): Additional notes to display in the help command.documentation
(String): Action-related documentation.stdinData
(String): The stdin data.
Converts the info input into json output.
- String|Object
info
: The info object or path to a json file.
- Object The info object.
Adds one or more options to the action object.
- Array|Object
input
: An array of option objects or an object passed to theTildaOption
class.
Creates the parser instance.
- Object
info
: Theinfo
object passed toTildaAction
. - Object
options
: Theoptions
passed toTildaAction
, extended with: defaultOptions
(Array): Default and global options (default: help and version options).argv
(Array): A cutom array of arguments to parse (default: process arguments).stdin
(Boolean): Whether to listen for stdin data or not (default:false
).
- Tilda The
Tilda
instance containing: actions
(Object): An object containing the action objects.version
(String): The version (used in help and version outputs).argv
(Array): Array of arguments to parse._globalOptions
(Array): The global options, appended to all the actions.actionNames
(Array): Action names in order.
Adds a global option for all the actions.
- Array|Object
input
: The option object.
Adds a new action.
- Object
input
: The info object passed toTildaAction
. - Array
opts
: The action options.
Exits the process.
- String|Object
msg
: The stringified message or an object containing the error code. - Number
code
: The exit code (default:0
).
Parses the arguments. This is called internally.
This emits the action names as events.
Returns the version information.
- String The version information.
Displays the help output.
- TildaAction
action
: The action you want to display help for.
Append a handler when the main action is used.
- Function
cb
: The callback function.
Converts an input into a class instance.
- Class
classConst
: The class to convert to. - Object|Array
input
: The object info. - Object
opts
: The options object (optional).
- TildaAction|TildaOption The input converted into a class instance.