UNPKG

skysync-cli

Version:

SkySync Command Line Interface

64 lines (63 loc) 2.23 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const command_1 = require("../../../util/command"); const outputFormat = { table: [ { header: 'ConnectionID', property: 'id' }, { header: 'ConnectionName', property: 'name' }, { header: 'Enabled', property: 'disabled', transform: val => !val }, { header: 'PoolID', property: 'pool.id' }, { header: 'PoolName', property: 'pool.name', } ] }; module.exports = { command: 'assign <id>', desc: 'Assign a connection to an existing connection pool, or create one if it does not exist.', builder: yargs => { yargs.options({ 'pool': { desc: 'Existing Connection Pool ID', type: 'string', }, 'name': { desc: 'New or Existing Connection Pool Name', type: 'string' } }); }, handler: argv => { command_1.runCommand(argv, (client, output) => __awaiter(void 0, void 0, void 0, function* () { const connection = yield client.connections.assignPool(argv.id, { id: argv.pool, name: argv.name }, { fields: ['name', 'disabled', 'pool.id', 'pool.name'] }); output.writeItem(connection, outputFormat); })); } };