Executes commands by calling the appropriate command-function from the commandLibrary, which will actually be stored functions on the D-Data structure.
- Copyright:
- Copyright © 2022-… by Seth Hollingsead. All rights reserved
- Source:
Requires
- module:ruleBroker
- module:commandsLibrary
- module:configurator
- module:loggers
- module:data
- module:stack
- haystacks
- @haystacks/constants
- path
Methods
(inner) addClientCommands(clientCommands) → {void}
Merges client defined commands with the system defined commands.
Parameters:
| Name | Type | Description |
|---|---|---|
clientCommands |
array.<object> | The client rules that should be merged with the system rules. |
- Source:
Returns:
- Type
- void
(inner) bootStrapCommands() → {void}
Captures all of the commands string-to-function cal map data in the commandsLibrary and migrates that dat a to the D-data structure. This is important now because we are going to allow the client to define their own commands separate from the system defined commands. So we need a way to merge al the client defined and system defined commands into one location. Then the command broker will execute commands rom the D-Data structure and not the commands library per-say. This will allow the system to expand much more dynamically and even be user-defined & flexible to client needs.
- Source:
Returns:
- Type
- void
(inner) countMatchingCommandAlias(commandAliasData, commandAliasName) → {integer}
This is a recursive function that searches through all teh command aliases data structures and counts the number of command aliases that match the input alias.
Parameters:
| Name | Type | Description |
|---|---|---|
commandAliasData |
object | The command alias data that should be searched recursively for the specified command alias. |
commandAliasName |
string | The command alias name/string that should be searched for and counted when matches are found. |
- Source:
Returns:
The count of the number of command aliases that match the given input alias.
- Type
- integer
(inner) executeCommand(commandString) → {array.<boolean, (string|integer|boolean|object|array)>}
Takes a command string with all its associated arguments, data & meta-data. This function will parse all of that out of the command lien variable that is passed in. And finally pass all of that data on the execution of the actual command.
Parameters:
| Name | Type | Description |
|---|---|---|
commandString |
string | The command to execute along with all the associated command arguments, data & meta-data. |
- Source:
Returns:
An array with a boolean True or False value to indicate if the application should exit or not exit, followed by the command output.
- Type
- array.<boolean, (string|integer|boolean|object|array)>
(inner) getAllCommandAliasData(commandAliasDataStructure) → {array.<string>|boolean}
Recursively gets all of the commands alias data from all levels and flattens them into a single array for printing out to the help command.
Parameters:
| Name | Type | Description |
|---|---|---|
commandAliasDataStructure |
object | The command alias data structure that should be recursively flattened into a single array for output. If the input is undefined then the main CommandsAliases data structure will be used at the root of the command aliases data hive. |
- Source:
Returns:
An array of all the command aliases currently needing to be flattened or a boolean True or False to indicate that a leaf-node has been found by the recursive caller.
- Type
- array.<string> | boolean
(inner) getCommandArgs(commandString, commandDelimiter) → {array.<(boolean|string|integer)>}
Gets the arguments of the current command.
Parameters:
| Name | Type | Description |
|---|---|---|
commandString |
string | The command string that should be parsed fro command arguments. |
commandDelimiter |
string | The delimiter that should be used to parse the command line. |
- Source:
Returns:
Any array of arguments, some times these might actually be nested command calls.
- Type
- array.<(boolean|string|integer)>
(inner) getCommandNamespaceDataObject(commandAliasDataStructure, namespaceToFind) → {object|boolean}
Recursively scans through the entire command alias data structure looking for an object that matches the input namespace name. When that namespace is found, the entire object is returned.
Parameters:
| Name | Type | Description |
|---|---|---|
commandAliasDataStructure |
object | The command alias data structure that should be recursively searched for the namespace specified. if the input is undefined then the main cCommandsAliases data structure will be used at the root of the CommandAliases data hive. |
namespaceToFind |
string | The namespace to look for in the command alias metaData data structure. |
- Source:
Returns:
The namespace object if it is found, or False if the namespace object was not found.
- Type
- object | boolean
(inner) getValidCommand(commandString, commandDelimiter) → {boolean|string}
Parses the command string and returns an array that can be used to enqueue or execute that command. Useful for determining if a command is a valid command and working with multiple levels of delimiters for nested command calls, looking up a command alias, etc...
Parameters:
| Name | Type | Description |
|---|---|---|
commandString |
string | The command string that should be parsed for a valid command. |
commandDelimiter |
string | The delimiter that should be used to parse the command line. |
- Source:
Returns:
False if the command is not valid, otherwise it returns the command string.
- Type
- boolean | string
(inner) searchCommandAlias(commandAliasData, commandAliasName) → {object}
This is a recursive function that searches through all the command aliases data structures and returns the one command data object that matches the input name.
Parameters:
| Name | Type | Description |
|---|---|---|
commandAliasData |
object | The command alias data that should be searched recursively for the specified command alias. |
commandAliasName |
string | The command alias name/string that should be found. |
- Source:
Returns:
The command object that corresponds to the input command alias name.
- Type
- object