UNPKG

skysync-cli

Version:

SkySync Command Line Interface

54 lines (53 loc) 2.25 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 fs = require("fs"); const command_1 = require("../../util/command"); const util_1 = require("./util"); module.exports = { command: 'clone <id>', desc: 'Clone job', builder: yargs => { yargs.options({ 'name': { desc: 'The job name', type: 'string' }, 'job-input': { alias: 'in', desc: 'Read JSON options from stdin', type: 'boolean' }, 'job-file': { alias: 'file', desc: 'The options JSON file', type: 'string' } }); }, handler: argv => { command_1.runCommand(argv, (client, output) => __awaiter(void 0, void 0, void 0, function* () { let jobCliParameters = Object.assign({}, argv.name && { name: argv.name }); let jobParametersInput = argv.jobInput ? yield command_1.readJsonInput() : undefined; if (!jobParametersInput) { jobParametersInput = argv.jobFile ? JSON.parse(fs.readFileSync(argv.jobFile, 'utf-8')) : {}; } let job = Object.assign(jobParametersInput, jobCliParameters); job = yield client.jobs.clone(argv.id, job, { fields: [ 'name', 'status', 'disabled' ] }); output.writeItem(job, util_1.detailOutputFormat); })); } };