UNPKG

1.94 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 return new (P || (P = Promise))(function (resolve, reject) {
4 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7 step((generator = generator.apply(thisArg, _arguments || [])).next());
8 });
9};
10Object.defineProperty(exports, "__esModule", { value: true });
11const command_1 = require("../models/command");
12const opn = require('opn');
13class DocCommand extends command_1.Command {
14 constructor() {
15 super(...arguments);
16 this.name = 'doc';
17 this.description = 'Opens the official Angular API documentation for a given keyword.';
18 this.arguments = ['keyword'];
19 this.options = [
20 {
21 name: 'search',
22 aliases: ['s'],
23 type: Boolean,
24 default: false,
25 description: 'Search whole angular.io instead of just api.'
26 }
27 ];
28 }
29 validate(options) {
30 if (!options.keyword) {
31 this.logger.error(`keyword argument is required.`);
32 return false;
33 }
34 }
35 run(options) {
36 return __awaiter(this, void 0, void 0, function* () {
37 let searchUrl = `https://angular.io/api?query=${options.keyword}`;
38 if (options.search) {
39 searchUrl = `https://www.google.com/search?q=site%3Aangular.io+${options.keyword}`;
40 }
41 return opn(searchUrl);
42 });
43 }
44}
45DocCommand.aliases = ['d'];
46exports.default = DocCommand;
47//# sourceMappingURL=/Users/hansl/Sources/hansl/angular-cli/commands/doc.js.map
\No newline at end of file