UNPKG

1.78 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) {
7 return {
8 title: c.title,
9 id: c.id,
10 description: c.description,
11 usage: c.usage,
12 hidden: c.hidden,
13 aliases: c.aliases || [],
14 flags: util_1.mapValues(c.flags || {}, (flag, name) => {
15 if (flag.type === 'boolean') {
16 return {
17 name,
18 type: flag.type,
19 char: flag.char,
20 description: flag.description,
21 hidden: flag.hidden,
22 required: flag.required,
23 };
24 }
25 return {
26 name,
27 type: flag.type,
28 char: flag.char,
29 description: flag.description,
30 hidden: flag.hidden,
31 required: flag.required,
32 helpValue: flag.helpValue,
33 options: flag.options,
34 default: typeof flag.default === 'function' ? flag.default({ options: {}, flags: {} }) : flag.default,
35 };
36 }),
37 args: c.args ? c.args.map(a => ({
38 name: a.name,
39 description: a.description,
40 required: a.required,
41 options: a.options,
42 default: typeof a.default === 'function' ? a.default({}) : a.default,
43 hidden: a.hidden,
44 })) : {},
45 };
46 }
47 Command.toCached = toCached;
48})(Command = exports.Command || (exports.Command = {}));