UNPKG

@villedemontreal/scripting

Version:
32 lines 1.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TestingScriptWithArgs = void 0; const core_1 = require("@caporal/core"); const src_1 = require("../../src"); class TestingScriptWithArgs extends src_1.ScriptBase { get name() { return `${src_1.TESTING_SCRIPT_NAME_PREFIX}testingScriptWithArgs`; } get description() { return `Example of script with arguments and options that will be called by another script.`; } async configure(command) { command.argument(`<name>`, `a name`); command.option(`--port <number>`, `A port number`, { required: true, validator: core_1.program.NUMBER, }); command.option(`--delay <number>`, `A delay in ms`, { validator: core_1.program.NUMBER, }); command.option(`--throwError`, `Throw an error`); } async main() { this.logger.info(`Start service ${this.args.name} on port ${this.options.port} with delay ${String(this.options.delay)}, --verbose: ${String(this.options.verbose)}`); if (this.options.throwError) { throw new Error('Some error...'); } } } exports.TestingScriptWithArgs = TestingScriptWithArgs; //# sourceMappingURL=testingScriptWithArgs.js.map