msbot
Version:
MSBot command line tool for manipulating Microsoft Bot Framework .bot files
61 lines • 2.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Copyright(c) Microsoft Corporation.All rights reserved.
* Licensed under the MIT License.
*/
// tslint:disable:no-console
// tslint:disable:no-object-literal-type-assertion
const botframework_config_1 = require("botframework-config");
const chalk = require("chalk");
const program = require("commander");
const process = require("process");
program.Command.prototype.unknownOption = (flag) => {
console.error(chalk.default.redBright(`Unknown arguments: ${flag}`));
showErrorHelp();
};
program
.name('msbot get <serviceNameOrId>')
.option('-b, --bot <path>', 'path to bot file. If omitted, local folder will look for a .bot file')
.option('--secret <secret>', 'bot file secret password for encrypting service secrets')
.option('--prefix', 'Append [msbot] prefix to all messages')
.action((cmd, actions) => undefined);
const command = program.parse(process.argv);
const args = {};
Object.assign(args, command);
if (!args.bot) {
botframework_config_1.BotConfiguration.loadBotFromFolder(process.cwd(), args.secret)
.then(processListArgs)
.catch((reason) => {
console.error(chalk.default.redBright(reason.toString().split('\n')[0]));
showErrorHelp();
});
}
else {
botframework_config_1.BotConfiguration.load(args.bot, args.secret)
.then(processListArgs)
.catch((reason) => {
console.error(chalk.default.redBright(reason.toString().split('\n')[0]));
showErrorHelp();
});
}
async function processListArgs(config) {
if (args.args.length < 2) {
throw new Error('missing the service id or name');
}
const nameOrId = args.args[0];
const service = config.findServiceByNameOrId(nameOrId);
if (service == null) {
throw new Error(`${nameOrId} was not found in ${config.getPath()}`);
}
console.log(JSON.stringify(service, null, 4));
return config;
}
function showErrorHelp() {
program.outputHelp((str) => {
console.error(str);
return '';
});
process.exit(1);
}
//# sourceMappingURL=msbot-get.js.map