@villedemontreal/scripting
Version:
Scripting core utilities
32 lines • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TestingScriptWithArgs = void 0;
const caporal_1 = require("@villedemontreal/caporal");
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: caporal_1.program.NUMBER,
});
command.option(`--delay <number>`, `A delay in ms`, {
validator: caporal_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