Parse command line arguments using minimist and store the parsed object into app.argv, and add app.showUsage() helper function
- Source:
- features/commandLine.js
Classes
Members
-
<static> type :string
-
This feature is loaded at initialization stage
Type:
- string
- Source:
- features/commandLine.js
Methods
-
<static> load_(app, usageOptions)
-
Load the feature
Parameters:
Name Type Description appApp The cli app module object
usageOptionsobject Options for the feature
- Source:
- features/commandLine.js
Properties:
Name Type Argument Description usageOptions.bannerstring <optional>
Banner message or banner generator function
usageOptions.programstring <optional>
Executable name
usageOptions.argumentsarray <optional>
Command line arguments, identified by the position of appearance
usageOptions.optionsobject <optional>
Command line options
usageOptions.silentModeboolean | function <optional>
Whether to run in silient mode, default false
usageOptions.nonValidationModeboolean | function <optional>
Whether to run validation
usageOptions.showUsageOnErrorboolean <optional>
Returns:
- Type
- Promise.<*>
Example
options: { [argumentKey]: { desc, // {string} - description alias, // {array.<string>} - alias array bool, // {boolean} - whether it is a boolean value default, // {*} - default value inquire, // {boolean | function(cli).<boolean>} - whether to enable interactive query promptMessage, // {string} - prompt message for query, will use desc if not set promptType, // {string} - prompt type, can be one of [ input, number, confirm, list, rawlist, expand, checkbox, password, editor ] promptDefault, // {* | function(cli).<*>} - default value appeared on query or a async function to return the default value choicesProvider, // {array | function(cli).<array> | function.<function(string).<array>>} - required for prompt type list, rawlist, expand, checkbox filter, // {function(argv, cli).<argv>} - filter to process the argument value afterInquire, // {function} - after inquire hook, onArgumentExists, // {function} - when argument exists, silentModeDefault // {*} - default value when run in silient mode, } }