UNPKG

msbot

Version:

MSBot command line tool for manipulating Microsoft Bot Framework .bot files

62 lines 2.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Copyright(c) Microsoft Corporation.All rights reserved. * Licensed under the MIT License. */ const chalk = require("chalk"); const program = require("commander"); const BotConfig_1 = require("./BotConfig"); program.Command.prototype.unknownOption = function (flag) { console.error(chalk.default.redBright(`Unknown arguments: ${flag}`)); showErrorHelp(); }; program .name('msbot disconnect') .arguments('<service_id_or_Name>') .description('disconnect a connected service by id or name') .option('-b, --bot <path>', 'path to bot file. If omitted, local folder will look for a .bot file') .action((idOrName, actions) => { actions.idOrName = idOrName; }); let args = program.parse(process.argv); if (process.argv.length < 3) { program.help(); } else { if (!args.bot) { BotConfig_1.BotConfig.LoadBotFromFolder(process.cwd()) .then(processConnectAzureArgs) .catch((reason) => { console.error(chalk.default.redBright(reason.toString().split('\n')[0])); showErrorHelp(); }); } else { BotConfig_1.BotConfig.Load(args.bot) .then(processConnectAzureArgs) .catch((reason) => { console.error(chalk.default.redBright(reason.toString().split('\n')[0])); showErrorHelp(); }); } } async function processConnectAzureArgs(config) { if (!args.idOrName) { throw new Error('missing id or name of service to disconnect'); } let removedService = config.disconnectServiceByNameOrId(args.idOrName); if (removedService != null) { await config.save(); process.stdout.write(`Disconnected ${removedService.type}:${removedService.name} ${removedService.id}`); } return config; } function showErrorHelp() { program.outputHelp((str) => { console.error(str); return ''; }); process.exit(1); } //# sourceMappingURL=msbot-disconnect.js.map