Class: CommandContext

CommandContext

The CommandContext is used to provide a command with additional information that it requires in order to fullfill its task successfully. You can use a server request as commandContext or create it manually, by adding your own parameters via the addParameter method.

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:
  • ruckola
Source:

Members

action :string

Type:
  • string
Default Value:
  • "macro"
Source:

macroID :Number

Type:
  • Number
Default Value:
  • False
Source:

parameters :Object

Type:
  • Object
Default Value:
  • Null
Source:

request :Object

Type:
  • Object
Default Value:
  • false
Source:

userCommandsRootDir :string

Type:
  • string
Default Value:
  • false
Source:

userConfigFile :string

Type:
  • string
Default Value:
  • false
Source:

userConfiguration :string

Type:
  • string
Default Value:
  • false
Source:

userHelperDir :string

Type:
  • string
Default Value:
  • false
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