CliAppUnit

flitter-cli/CliAppUnit~ CliAppUnit

Final unit to run the ./flitter CLI utility. This will replace the default module:libflitter/app/AppUnit~AppUnit.


Constructor

new CliAppUnit()

Members

(static) name

Get the name of the service provided by this unit: 'CliApp'

(static) services

Defines the services required by this unit.

Methods

get_help_option() → {module:flitter-cli/options/FlagOption~FlagOption}

Get the flag option that signals help. Usually, this is named 'help' and supports the flags '--help' and '-?'.

(async) go(app, argvopt) → {Promise.<void>}

Loads the unit. Retrieves the CLI arguments and passes control off to the appropriate module:flitter-cli/Directive~Directive handler.

Parameters:
Name Type Attributes Default Description
app module:libflitter/app/FlitterApp~FlitterApp

the Flitter app

argv Array.<string> <optional>
process.argv.slice(2)

the CLI argv to be interpreted

Returns:
Type
Promise.<void>

(async) handle_directive(app, DirectiveClass, args) → {Promise.<void>}

Handles an invocation of the specified directive class with the provided arguments.

Parameters:
Name Type Description
app module:libflitter/app/FlitterApp~FlitterAPp

the Flitter app

DirectiveClass module:flitter-cli/Directive~Directive

the static CLASS of the directive

args Array.<string>

the raw CLI arguments

Returns:
Type
Promise.<void>

option_from_string(string) → {module:flitter-cli/options/FlagOption~FlagOption|module:flitter-cli/options/PositionalOption~PositionalOption}

Create an instance of module:flitter-cli/options/Option~Option based on a string definition of a particular format.

e.g. '{file name} | canonical name of the resource to create' e.g. '--push -p {value} | the value to be pushed' e.g. '--force -f | do a force push'

Parameters:
Name Type Description
string

process_options(option_classes, args) → {object}

Process the raw CLI arguments using an array of option class instances to build a mapping of option names to provided values.

Parameters:
Name Type Description
option_classes Array.<module:flitter-cli/option/Option~Option>

array of option definitions

args Array.<string>

the raw CLI args

Returns:
  • the parsed options, by name
Type
object

requested_usage(args) → {boolean}

Determines if, at any point in the arguments, the help option's short or long flag appears.

Parameters:
Name Type Description
args Array.<string>

the raw CLI args

Returns:
  • true if the help flag appeared
Type
boolean