Constructor
new CommandContext(request)
The CommandContext is an object that is passed as a parameter
to each new command at instantiation. You can add new parameters to fit your own needs.
Parameters:
Name |
Type |
Description |
request |
object
|
A server request object with an 'action' member.
for example {action:"myCommand"} |
Properties:
Name |
Type |
Attributes |
Default |
Description |
parameters |
object
|
<optional>
|
{}
|
Contains the key-value pairs that are needed to run a command.
Properties
Name |
Type |
Attributes |
Default |
Description |
action |
string
|
<optional>
|
"macro"
|
The name of the command to be invoked, sets CommandContext#action. |
macroID |
boolean
|
<optional>
|
false
|
The id of the macro as specified in the config.json file. |
request |
boolean
|
<optional>
|
false
|
A Server request (optional) CommandContext#request. |
userConfigFile |
boolean
|
<optional>
|
false
|
The absolute path to the config.json file of your project.
(this filepath must be specified as a relative path in the config.json of the macro-command package. You can find it here: "./node_modules/macro-command/config/config.json". |
userCommandsRootDir |
boolean
|
<optional>
|
false
|
The path to the root of your 'commands' directory. (this path must
be specified as a relative path in the config.json of the macro-command package. You can find it here: "./node_modules/macro-command/config/config.json". |
userHelperDir |
boolean
|
<optional>
|
false
|
The path to the helper directory. (this path must
be specified as a relative path in the config.json of the macro-command package. You can find it here: "./node_modules/macro-command/config/config.json". |
userConfiguration |
boolean
|
<optional>
|
false
|
The content of the userConfigFile. |
|
- Author:
-
- Source:
Members
action :string
Type:
- Default Value:
- Source:
macroID :Number
Type:
- Default Value:
- Source:
parameters :Object
Type:
- Default Value:
- Source:
request :Object
Type:
- Default Value:
- Source:
userCommandsRootDir :string
Type:
- Default Value:
- Source:
userConfigFile :string
Type:
- Default Value:
- Source:
userConfiguration :string
Type:
- Default Value:
- Source:
userHelperDir :string
Type:
- Default Value:
- Source:
Methods
addParameter(key, value)
Add a new member (key-value pair) to the context parameters.
Parameters:
Name |
Type |
Description |
key |
string
|
Name of the new key that will be added to the context parameters. |
value |
any
|
Any value for the new key; |
- Source:
get(key) → {value}
Add a new member (key-value pair) to the context parameters.
Parameters:
Name |
Type |
Description |
key |
string
|
Name of the member to return. |
- Source:
Returns:
The value of member[key].
-
Type
-
value