Module: Feature_CommandLine

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

CommandLine
CommandLineArgumentError

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
app App

The cli app module object

usageOptions object

Options for the feature

Properties:
Name Type Argument Description
usageOptions.banner string <optional>

Banner message or banner generator function

usageOptions.program string <optional>

Executable name

usageOptions.arguments array <optional>

Command line arguments, identified by the position of appearance

usageOptions.options object <optional>

Command line options

usageOptions.silentMode boolean | function <optional>

Whether to run in silient mode, default false

usageOptions.nonValidationMode boolean | function <optional>

Whether to run validation

usageOptions.showUsageOnError boolean <optional>
Source:
features/commandLine.js
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,
  } }