CliUnit

flitter-cli/CliUnit~ CliUnit

Unit that provides the functionality associated with flitter-cli.


Constructor

new CliUnit()

Extends

Members

(static) name

Gets the name of the service provided by this unit: 'cli'

(static) services

Defines the services required by this unit.

(private) _di_allow_defer :boolean

If true, the injector will defer the class if the class requests any services that the container is missing. These services are filled in later and added to the prototype and any instances. True by default.

Type:
  • boolean

(private) _di_deferred_instances :Array.<module:flitter-di/src/Injectable~Injectable>

Collection of instances of this class that need to have the deferred service instances injected into them when the deferred services are finally provided.

(private) _di_deferred_services :Array.<string>

List of services that were deferred and not provided at the time of injection.

Type:
  • Array.<string>

Methods

(async) cleanup(app) → {Promise.<void>}

Cleans up the unit's resources before Flitter closes.

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

the Flitter app

Returns:
Type
Promise.<void>

directives() → {Object}

Get the directive classes provided by this unit. Should be key-value pairs such that the key is the name of the class, and the value is an instance of module:flitter-cli/Directive~Directive.

Returns:
Type
Object

directories() → {Object}

Get the directories provided by the unit. Should be an object such that key => value is the name of the directory => fully qualified path to the directory.

Returns:
Type
Object

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

Loads the module. If any registered unit has deployments/templates/directives, register them with flitter-cli. Register the help messages to be used by ./flitter help. Then, bind them all to the context.

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

the Flitter app

context module:libflitter/Context~Context

the Unit's context

Returns:
Type
Promise.<void>

(async) invoke(directive, argv) → {Promise.<Array>}

Invoke a command, programmatically. Replaces console.log with a pseudo function that collects messages.

Parameters:
Name Type Description
directive string

the directive to be called

argv Array.<string>

array of command line arguments

Returns:
  • array of items that were sent to console.log during the command's execution
Type
Promise.<Array>

name() → {string}

Get the name of the unit.

Returns:

"cli"

Type
string

status(setopt) → {string}

Get or set the unit's current status.

Parameters:
Name Type Attributes Description
set string <optional>

if provided, set the status of the unit

Returns:
  • current status of the unit
Type
string