UNPKG

2.1 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const util_1 = require("./util");
4var Command;
5(function (Command) {
6 // eslint-disable-next-line no-inner-declarations
7 function toCached(c, plugin) {
8 return {
9 id: c.id,
10 description: c.description,
11 usage: c.usage,
12 pluginName: plugin && plugin.name,
13 pluginType: plugin && plugin.type,
14 hidden: c.hidden,
15 aliases: c.aliases || [],
16 examples: c.examples || c.example,
17 flags: util_1.mapValues(c.flags || {}, (flag, name) => {
18 if (flag.type === 'boolean') {
19 return {
20 name,
21 type: flag.type,
22 char: flag.char,
23 description: flag.description,
24 hidden: flag.hidden,
25 required: flag.required,
26 helpLabel: flag.helpLabel,
27 allowNo: flag.allowNo,
28 };
29 }
30 return {
31 name,
32 type: flag.type,
33 char: flag.char,
34 description: flag.description,
35 hidden: flag.hidden,
36 required: flag.required,
37 helpLabel: flag.helpLabel,
38 helpValue: flag.helpValue,
39 options: flag.options,
40 default: typeof flag.default === 'function' ? flag.default({ options: {}, flags: {} }) : flag.default,
41 };
42 }),
43 args: c.args ? c.args.map(a => ({
44 name: a.name,
45 description: a.description,
46 required: a.required,
47 options: a.options,
48 default: typeof a.default === 'function' ? a.default({}) : a.default,
49 hidden: a.hidden,
50 })) : [],
51 };
52 }
53 Command.toCached = toCached;
54})(Command = exports.Command || (exports.Command = {}));