@absolunet/ioc2.1.0

View on GitHub

CommandRegistrar

Class that registers the command and bootstraps all the needed instances in order to make the CLI engine works.

Members

(static) dependencies :Array.<string>

Source:
Class dependencies: ['app', 'command', 'command.runner', 'file', 'terminal', 'yargs'].

handlers :Array.<Promise.<*>>

Source:
Currently running command handlers.

commandRepository :console.repositories.CommandRepository

Source:
The command repository.

Methods

add(command)

Source:
Add a command in the repository.
Parameters:
Name Type Description
command function A command to add.

addFromFolder(folder)

Source:
Add all commands in the given folder.
Parameters:
Name Type Description
folder string A folder from which load commands.

setDefault(Command)

Source:
Set default command to be executed of nothing is provided.
Parameters:
Name Type Description
Command console.Command | function The default command.

getDefault()

Source:
Retrieve default command from the command repository.
Returns:
The default command instance.
Type
console.Command | null

(async) resolve(command, internalopt)

Source:
Resolve given console command by getting the related Command instance and make it handle the request.
Parameters:
Name Type Attributes Default Description
command string | Array.<string> The command to resolve.
internal boolean <optional>
false Specify if the command should be processed as an internal process. If if should check the policies restrictions, set to false.
Returns:
The async process promise.
Type
Promise

bootstrap(yargs, withPoliciesopt)

Source:
Bootstrap the commands in Yargs.
Parameters:
Name Type Attributes Default Description
yargs yargs The Yargs instance.
withPolicies boolean <optional>
true Indicates that the policies should be checked before bootstrapping them.