Class: Cli

Cli(opts)

new Cli(opts)

Parameters:
Name Type Description
opts Object CLI options
Properties
Name Type Attributes Description
run Cli~runBridge The function called when you should run the bridge.
generateRegistration Cli~generateRegistration The function called when you should generate a registration.
bridgeConfig Object <optional>
Bridge-specific config info. If null, no --config option will be present in the CLI. Default: null.
Properties
Name Type Attributes Description
affectsRegistration boolean <optional>
True to make the --config option required when generating the registration. The parsed config can be accessed via Cli.getConfig().
schema string | Object Path to a schema YAML file (string) or the parsed schema file (Object).
defaults Object <optional>
The default options for the config file.
enableRegistration boolean <optional>
Enable '--generate-registration'. Default True.
registrationPath string <optional>
The path to write the registration file to. Users can overwrite this with -f.
enableLocalpart boolean <optional>
Enable '--localpart [-l]'. Default: false.
Source:

Methods

getConfig() → (nullable) {Object}

Get the loaded and parsed bridge config. Only set after run() has been called.
Source:
Returns:
The config
Type
Object

getRegistrationFilePath() → {string}

Get the path to the registration file. This may be different to the one supplied in the constructor if the user passed a -f flag.
Source:
Returns:
The path to the registration file.
Type
string

run()

Run the app from the command line. Will parse sys args.
Source:

Type Definitions

generateRegistration(reg, callback)

Invoked when you should generate a registration.
Parameters:
Name Type Description
reg AppServiceRegistration A new registration object with the app service url provided by --url set.
callback function The callback that you should invoke when the registration has been generated. It should be called with the AppServiceRegistration provided in this function.
Source:
Example
generateRegistration: function(reg, callback) {
  reg.setHomeserverToken(AppServiceRegistration.generateToken());
  reg.setAppServiceToken(AppServiceRegistration.generateToken());
  reg.setSenderLocalpart("my_first_bot");
  callback(reg);
}

runBridge(port, confignullable, reg)

Invoked when you should run the bridge.
Parameters:
Name Type Attributes Description
port Number The port to listen on.
config Object <nullable>
The loaded and parsed config.
reg AppServiceRegistration The registration to run as.
Source:
Example
runBridge: function(port, config, reg) {
  // configure bridge
  // listen on port
}