UNPKG

2.13 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4 return new (P || (P = Promise))(function (resolve, reject) {
5 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8 step((generator = generator.apply(thisArg, _arguments || [])).next());
9 });
10};
11Object.defineProperty(exports, "__esModule", { value: true });
12exports.AddCommand = void 0;
13const remaining_flags_1 = require("../lib/utils/remaining-flags");
14const abstract_command_1 = require("./abstract.command");
15class AddCommand extends abstract_command_1.AbstractCommand {
16 load(program) {
17 program
18 .command('add <library>')
19 .allowUnknownOption()
20 .description('Adds support for an external library to your project.')
21 .option('-d, --dry-run', 'Report actions that would be performed without writing out results.')
22 .option('-p, --project [project]', 'Project in which to generate files.')
23 .usage('<library> [options] [library-specific-options]')
24 .action((library, command) => __awaiter(this, void 0, void 0, function* () {
25 const options = [];
26 options.push({ name: 'dry-run', value: !!command.dryRun });
27 options.push({
28 name: 'project',
29 value: command.project,
30 });
31 const inputs = [];
32 inputs.push({ name: 'library', value: library });
33 const flags = (0, remaining_flags_1.getRemainingFlags)(program);
34 try {
35 yield this.action.handle(inputs, options, flags);
36 }
37 catch (err) {
38 process.exit(1);
39 }
40 }));
41 }
42}
43exports.AddCommand = AddCommand;