# Module: chiefCommander

Holds all of the functions that manage the command queue, and allows commands to be enqueued and dequeued from the command queue. Also executes the command queue ultimately by making calls to the commandBroker to execute individual commands.

Author:
  - Seth Hollingsead
Copyright:
  - Copyright © 2022-… by Seth Hollingsead. All rights reserved
Source:
  - controllers/chiefCommander.js, line 1

### Requires

- module:commandBroker
- module:chiefData
- module:loggers
- module:data
- module:queue
- module:stack
- @haystacks/constants
- path

### Methods

#### (inner) addClientCommands(clientCommands) → {void}

This is a wrapper function for calling the commandBroker.addClientCommands.

##### Parameters:

Name | Type | Description
--- | --- | ---
`clientCommands` | object | A map of client defined command names and client defined command function calls.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefCommander.js, line 64

##### Returns:

Type
  void

#### (inner) bootStrapCommands() → {void}

Initializes all of the commands and gets them added to the D-data structure.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefCommander.js, line 36

##### Returns:

Type
  void

#### (inner) enqueueCommand(command) → {void}

Determines if the command queue has been setup or not, if not then it is initialized, and the command is added to the command queue.

##### Parameters:

Name | Type | Description
--- | --- | ---
`command` | string | The command that should be added to the command queue.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefCommander.js, line 135

##### Returns:

Type
  void

#### (inner) isCommandQueueEmpty() → {boolean}

Determines if the command queue is empty or not empty.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefCommander.js, line 161

##### Returns:

A True or False value to indicate if the command queue is empty or not empty.

Type
  boolean

#### (inner) loadCommandAliasesFromPath(commandAliasesFilePathConfigurationName, contextName) → {boolean|object}

Loads the command aliases XML file that is specified by the input. The data is automatically saved on the D-data structure.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandAliasesFilePathConfigurationName` | string | The path and file name to the XML file that contains the command aliases definitions. (Could be system command aliases or client command aliases)
`contextName` | string | The context name defines what parent command alias namespace the loaded and merged data should be stored in. Example: contextName = "framework" => D['CommandsAliases']['Framework'] contextName = "application" => D['CommandAliases']['Application'] contextName = "plugin" => D['CommandAliases']['Plugins']['']

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefCommander.js, line 79

##### Returns:

True or False if the data to be loaded is not from a plugin, returns a JSON object is the data to be loaded is from a plugin.

Type
  boolean | object

#### (inner) processCommandQueue() → {array.<boolean, (string|integer|boolean|object|array)>}

Pulls the command from the front of the command queue and executes it using the command broker.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefCommander.js, line 178

##### 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) reinitializeCommands() → {void}

Clears out and then re-bootstraps the commands.

Author:
  - Seth Hollingsead
Source:
  - controllers/chiefCommander.js, line 50

##### Returns:

Type
  void