UNPKG

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