@xmorse/cac 6.0.2 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno/Command.ts +9 -11
- package/dist/index.js +7 -8
- package/dist/index.mjs +159 -187
- package/package.json +1 -1
package/deno/Command.ts
CHANGED
|
@@ -144,23 +144,13 @@ class Command {
|
|
|
144
144
|
title: 'Usage',
|
|
145
145
|
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
146
146
|
});
|
|
147
|
-
|
|
148
|
-
// Show full description for specific commands (not global/default)
|
|
149
|
-
if (!this.isGlobalCommand && !this.isDefaultCommand && this.description) {
|
|
150
|
-
sections.push({
|
|
151
|
-
title: 'Description',
|
|
152
|
-
body: this.description.split('\n').map(line => ` ${line}`).join('\n')
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
147
|
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
156
148
|
if (showCommands) {
|
|
157
149
|
const longestCommandName = findLongest(commands.map(command => command.rawName));
|
|
158
150
|
sections.push({
|
|
159
151
|
title: 'Commands',
|
|
160
152
|
body: commands.map(command => {
|
|
161
|
-
|
|
162
|
-
const firstLine = command.description.split('\n')[0].trim();
|
|
163
|
-
return ` ${padRight(command.rawName, longestCommandName.length)} ${firstLine}`;
|
|
153
|
+
return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
|
|
164
154
|
}).join('\n')
|
|
165
155
|
});
|
|
166
156
|
sections.push({
|
|
@@ -181,6 +171,14 @@ class Command {
|
|
|
181
171
|
}).join('\n')
|
|
182
172
|
});
|
|
183
173
|
}
|
|
174
|
+
|
|
175
|
+
// Show full description for specific commands (not global/default)
|
|
176
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand && this.description) {
|
|
177
|
+
sections.push({
|
|
178
|
+
title: 'Description',
|
|
179
|
+
body: this.description.split('\n').map(line => ` ${line}`).join('\n')
|
|
180
|
+
});
|
|
181
|
+
}
|
|
184
182
|
if (this.examples.length > 0) {
|
|
185
183
|
sections.push({
|
|
186
184
|
title: 'Examples',
|
package/dist/index.js
CHANGED
|
@@ -352,20 +352,13 @@ class Command {
|
|
|
352
352
|
title: "Usage",
|
|
353
353
|
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
354
354
|
});
|
|
355
|
-
if (!this.isGlobalCommand && !this.isDefaultCommand && this.description) {
|
|
356
|
-
sections.push({
|
|
357
|
-
title: "Description",
|
|
358
|
-
body: this.description.split("\n").map((line) => ` ${line}`).join("\n")
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
355
|
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
362
356
|
if (showCommands) {
|
|
363
357
|
const longestCommandName = findLongest(commands.map((command) => command.rawName));
|
|
364
358
|
sections.push({
|
|
365
359
|
title: "Commands",
|
|
366
360
|
body: commands.map((command) => {
|
|
367
|
-
|
|
368
|
-
return ` ${padRight(command.rawName, longestCommandName.length)} ${firstLine}`;
|
|
361
|
+
return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
|
|
369
362
|
}).join("\n")
|
|
370
363
|
});
|
|
371
364
|
sections.push({
|
|
@@ -386,6 +379,12 @@ class Command {
|
|
|
386
379
|
}).join("\n")
|
|
387
380
|
});
|
|
388
381
|
}
|
|
382
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand && this.description) {
|
|
383
|
+
sections.push({
|
|
384
|
+
title: "Description",
|
|
385
|
+
body: this.description.split("\n").map((line) => ` ${line}`).join("\n")
|
|
386
|
+
});
|
|
387
|
+
}
|
|
389
388
|
if (this.examples.length > 0) {
|
|
390
389
|
sections.push({
|
|
391
390
|
title: "Examples",
|
package/dist/index.mjs
CHANGED
|
@@ -1,140 +1,127 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
-
var __commonJS = (callback, module) => () => {
|
|
9
|
-
if (!module) {
|
|
10
|
-
module = {exports: {}};
|
|
11
|
-
callback(module.exports, module);
|
|
12
|
-
}
|
|
13
|
-
return module.exports;
|
|
14
|
-
};
|
|
15
|
-
var __exportStar = (target, module, desc) => {
|
|
16
|
-
if (module && typeof module === "object" || typeof module === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(module))
|
|
18
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
19
|
-
__defProp(target, key, {get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable});
|
|
20
|
-
}
|
|
21
|
-
return target;
|
|
22
|
-
};
|
|
23
|
-
var __toModule = (module) => {
|
|
24
|
-
return __exportStar(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? {get: () => module.default, enumerable: true} : {value: module, enumerable: true})), module);
|
|
25
|
-
};
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
26
2
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
if (defaults) {
|
|
66
|
-
for (k in opts.default) {
|
|
67
|
-
name = typeof opts.default[k];
|
|
68
|
-
arr = opts.alias[k] = opts.alias[k] || [];
|
|
69
|
-
if (opts[name] !== void 0) {
|
|
70
|
-
opts[name].push(k);
|
|
71
|
-
for (i = 0; i < arr.length; i++) {
|
|
72
|
-
opts[name].push(arr[i]);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const keys = strict ? Object.keys(opts.alias) : [];
|
|
78
|
-
for (i = 0; i < len; i++) {
|
|
79
|
-
arg = args[i];
|
|
80
|
-
if (arg === "--") {
|
|
81
|
-
out._ = out._.concat(args.slice(++i));
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
for (j = 0; j < arg.length; j++) {
|
|
85
|
-
if (arg.charCodeAt(j) !== 45)
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
if (j === 0) {
|
|
89
|
-
out._.push(arg);
|
|
90
|
-
} else if (arg.substring(j, j + 3) === "no-") {
|
|
91
|
-
name = arg.substring(j + 3);
|
|
92
|
-
if (strict && !~keys.indexOf(name)) {
|
|
93
|
-
return opts.unknown(arg);
|
|
94
|
-
}
|
|
95
|
-
out[name] = false;
|
|
96
|
-
} else {
|
|
97
|
-
for (idx = j + 1; idx < arg.length; idx++) {
|
|
98
|
-
if (arg.charCodeAt(idx) === 61)
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
name = arg.substring(j, idx);
|
|
102
|
-
val = arg.substring(++idx) || (i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i]);
|
|
103
|
-
arr = j === 2 ? [name] : name;
|
|
104
|
-
for (idx = 0; idx < arr.length; idx++) {
|
|
105
|
-
name = arr[idx];
|
|
106
|
-
if (strict && !~keys.indexOf(name))
|
|
107
|
-
return opts.unknown("-".repeat(j) + name);
|
|
108
|
-
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (defaults) {
|
|
113
|
-
for (k in opts.default) {
|
|
114
|
-
if (out[k] === void 0) {
|
|
115
|
-
out[k] = opts.default[k];
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (alibi) {
|
|
120
|
-
for (k in out) {
|
|
121
|
-
arr = opts.alias[k] || [];
|
|
122
|
-
while (arr.length > 0) {
|
|
123
|
-
out[arr.shift()] = out[k];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return out;
|
|
128
|
-
};
|
|
129
|
-
});
|
|
3
|
+
function toArr(any) {
|
|
4
|
+
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function toVal(out, key, val, opts) {
|
|
8
|
+
var x, old=out[key], nxt=(
|
|
9
|
+
!!~opts.string.indexOf(key) ? (val == null || val === true ? '' : String(val))
|
|
10
|
+
: typeof val === 'boolean' ? val
|
|
11
|
+
: !!~opts.boolean.indexOf(key) ? (val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val),!!val))
|
|
12
|
+
: (x = +val,x * 0 === 0) ? x : val
|
|
13
|
+
);
|
|
14
|
+
out[key] = old == null ? nxt : (Array.isArray(old) ? old.concat(nxt) : [old, nxt]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function mri (args, opts) {
|
|
18
|
+
args = args || [];
|
|
19
|
+
opts = opts || {};
|
|
20
|
+
|
|
21
|
+
var k, arr, arg, name, val, out={ _:[] };
|
|
22
|
+
var i=0, j=0, idx=0, len=args.length;
|
|
23
|
+
|
|
24
|
+
const alibi = opts.alias !== void 0;
|
|
25
|
+
const strict = opts.unknown !== void 0;
|
|
26
|
+
const defaults = opts.default !== void 0;
|
|
27
|
+
|
|
28
|
+
opts.alias = opts.alias || {};
|
|
29
|
+
opts.string = toArr(opts.string);
|
|
30
|
+
opts.boolean = toArr(opts.boolean);
|
|
31
|
+
|
|
32
|
+
if (alibi) {
|
|
33
|
+
for (k in opts.alias) {
|
|
34
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
35
|
+
for (i=0; i < arr.length; i++) {
|
|
36
|
+
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
130
40
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
41
|
+
for (i=opts.boolean.length; i-- > 0;) {
|
|
42
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
43
|
+
for (j=arr.length; j-- > 0;) opts.boolean.push(arr[j]);
|
|
44
|
+
}
|
|
134
45
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
46
|
+
for (i=opts.string.length; i-- > 0;) {
|
|
47
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
48
|
+
for (j=arr.length; j-- > 0;) opts.string.push(arr[j]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (defaults) {
|
|
52
|
+
for (k in opts.default) {
|
|
53
|
+
name = typeof opts.default[k];
|
|
54
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
55
|
+
if (opts[name] !== void 0) {
|
|
56
|
+
opts[name].push(k);
|
|
57
|
+
for (i=0; i < arr.length; i++) {
|
|
58
|
+
opts[name].push(arr[i]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
65
|
+
|
|
66
|
+
for (i=0; i < len; i++) {
|
|
67
|
+
arg = args[i];
|
|
68
|
+
|
|
69
|
+
if (arg === '--') {
|
|
70
|
+
out._ = out._.concat(args.slice(++i));
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
for (j=0; j < arg.length; j++) {
|
|
75
|
+
if (arg.charCodeAt(j) !== 45) break; // "-"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (j === 0) {
|
|
79
|
+
out._.push(arg);
|
|
80
|
+
} else if (arg.substring(j, j + 3) === 'no-') {
|
|
81
|
+
name = arg.substring(j + 3);
|
|
82
|
+
if (strict && !~keys.indexOf(name)) {
|
|
83
|
+
return opts.unknown(arg);
|
|
84
|
+
}
|
|
85
|
+
out[name] = false;
|
|
86
|
+
} else {
|
|
87
|
+
for (idx=j+1; idx < arg.length; idx++) {
|
|
88
|
+
if (arg.charCodeAt(idx) === 61) break; // "="
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
name = arg.substring(j, idx);
|
|
92
|
+
val = arg.substring(++idx) || (i+1 === len || (''+args[i+1]).charCodeAt(0) === 45 || args[++i]);
|
|
93
|
+
arr = (j === 2 ? [name] : name);
|
|
94
|
+
|
|
95
|
+
for (idx=0; idx < arr.length; idx++) {
|
|
96
|
+
name = arr[idx];
|
|
97
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
|
|
98
|
+
toVal(out, name, (idx + 1 < arr.length) || val, opts);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (defaults) {
|
|
104
|
+
for (k in opts.default) {
|
|
105
|
+
if (out[k] === void 0) {
|
|
106
|
+
out[k] = opts.default[k];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (alibi) {
|
|
112
|
+
for (k in out) {
|
|
113
|
+
arr = opts.alias[k] || [];
|
|
114
|
+
while (arr.length > 0) {
|
|
115
|
+
out[arr.shift()] = out[k];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
|
|
124
|
+
const findAllBrackets = (v) => {
|
|
138
125
|
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
139
126
|
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
140
127
|
const res = [];
|
|
@@ -161,7 +148,7 @@ var findAllBrackets = (v) => {
|
|
|
161
148
|
}
|
|
162
149
|
return res;
|
|
163
150
|
};
|
|
164
|
-
|
|
151
|
+
const getMriOptions = (options) => {
|
|
165
152
|
const result = {alias: {}, boolean: []};
|
|
166
153
|
for (const [index, option] of options.entries()) {
|
|
167
154
|
if (option.names.length > 1) {
|
|
@@ -182,20 +169,20 @@ var getMriOptions = (options) => {
|
|
|
182
169
|
}
|
|
183
170
|
return result;
|
|
184
171
|
};
|
|
185
|
-
|
|
172
|
+
const findLongest = (arr) => {
|
|
186
173
|
return arr.sort((a, b) => {
|
|
187
174
|
return a.length > b.length ? -1 : 1;
|
|
188
175
|
})[0];
|
|
189
176
|
};
|
|
190
|
-
|
|
177
|
+
const padRight = (str, length) => {
|
|
191
178
|
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
192
179
|
};
|
|
193
|
-
|
|
180
|
+
const camelcase = (input) => {
|
|
194
181
|
return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
|
|
195
182
|
return p1 + p2.toUpperCase();
|
|
196
183
|
});
|
|
197
184
|
};
|
|
198
|
-
|
|
185
|
+
const setDotProp = (obj, keys, val) => {
|
|
199
186
|
let i = 0;
|
|
200
187
|
let length = keys.length;
|
|
201
188
|
let t = obj;
|
|
@@ -205,7 +192,7 @@ var setDotProp = (obj, keys, val) => {
|
|
|
205
192
|
t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
|
|
206
193
|
}
|
|
207
194
|
};
|
|
208
|
-
|
|
195
|
+
const setByType = (obj, transforms) => {
|
|
209
196
|
for (const key of Object.keys(transforms)) {
|
|
210
197
|
const transform = transforms[key];
|
|
211
198
|
if (transform.shouldTransform) {
|
|
@@ -216,16 +203,16 @@ var setByType = (obj, transforms) => {
|
|
|
216
203
|
}
|
|
217
204
|
}
|
|
218
205
|
};
|
|
219
|
-
|
|
206
|
+
const getFileName = (input) => {
|
|
220
207
|
const m = /([^\\\/]+)$/.exec(input);
|
|
221
208
|
return m ? m[1] : "";
|
|
222
209
|
};
|
|
223
|
-
|
|
210
|
+
const camelcaseOptionName = (name) => {
|
|
224
211
|
return name.split(".").map((v, i) => {
|
|
225
212
|
return i === 0 ? camelcase(v) : v;
|
|
226
213
|
}).join(".");
|
|
227
214
|
};
|
|
228
|
-
|
|
215
|
+
class CACError extends Error {
|
|
229
216
|
constructor(message) {
|
|
230
217
|
super(message);
|
|
231
218
|
this.name = this.constructor.name;
|
|
@@ -235,10 +222,9 @@ var CACError = class extends Error {
|
|
|
235
222
|
this.stack = new Error(message).stack;
|
|
236
223
|
}
|
|
237
224
|
}
|
|
238
|
-
}
|
|
225
|
+
}
|
|
239
226
|
|
|
240
|
-
|
|
241
|
-
var Option = class {
|
|
227
|
+
class Option {
|
|
242
228
|
constructor(rawName, description, config) {
|
|
243
229
|
this.rawName = rawName;
|
|
244
230
|
this.description = description;
|
|
@@ -265,15 +251,12 @@ var Option = class {
|
|
|
265
251
|
this.isBoolean = true;
|
|
266
252
|
}
|
|
267
253
|
}
|
|
268
|
-
}
|
|
269
|
-
var Option_default = Option;
|
|
254
|
+
}
|
|
270
255
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
var platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
256
|
+
const processArgs = process.argv;
|
|
257
|
+
const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
274
258
|
|
|
275
|
-
|
|
276
|
-
var Command = class {
|
|
259
|
+
class Command {
|
|
277
260
|
constructor(rawName, description, config = {}, cli) {
|
|
278
261
|
this.rawName = rawName;
|
|
279
262
|
this.description = description;
|
|
@@ -307,7 +290,7 @@ var Command = class {
|
|
|
307
290
|
return this;
|
|
308
291
|
}
|
|
309
292
|
option(rawName, description, config) {
|
|
310
|
-
const option = new
|
|
293
|
+
const option = new Option(rawName, description, config);
|
|
311
294
|
this.options.push(option);
|
|
312
295
|
return this;
|
|
313
296
|
}
|
|
@@ -365,20 +348,13 @@ var Command = class {
|
|
|
365
348
|
title: "Usage",
|
|
366
349
|
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
367
350
|
});
|
|
368
|
-
if (!this.isGlobalCommand && !this.isDefaultCommand && this.description) {
|
|
369
|
-
sections.push({
|
|
370
|
-
title: "Description",
|
|
371
|
-
body: this.description.split("\n").map((line) => ` ${line}`).join("\n")
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
351
|
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
375
352
|
if (showCommands) {
|
|
376
353
|
const longestCommandName = findLongest(commands.map((command) => command.rawName));
|
|
377
354
|
sections.push({
|
|
378
355
|
title: "Commands",
|
|
379
356
|
body: commands.map((command) => {
|
|
380
|
-
|
|
381
|
-
return ` ${padRight(command.rawName, longestCommandName.length)} ${firstLine}`;
|
|
357
|
+
return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
|
|
382
358
|
}).join("\n")
|
|
383
359
|
});
|
|
384
360
|
sections.push({
|
|
@@ -399,6 +375,12 @@ var Command = class {
|
|
|
399
375
|
}).join("\n")
|
|
400
376
|
});
|
|
401
377
|
}
|
|
378
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand && this.description) {
|
|
379
|
+
sections.push({
|
|
380
|
+
title: "Description",
|
|
381
|
+
body: this.description.split("\n").map((line) => ` ${line}`).join("\n")
|
|
382
|
+
});
|
|
383
|
+
}
|
|
402
384
|
if (this.examples.length > 0) {
|
|
403
385
|
sections.push({
|
|
404
386
|
title: "Examples",
|
|
@@ -454,16 +436,15 @@ ${section.body}` : section.body;
|
|
|
454
436
|
}
|
|
455
437
|
}
|
|
456
438
|
}
|
|
457
|
-
}
|
|
458
|
-
|
|
439
|
+
}
|
|
440
|
+
class GlobalCommand extends Command {
|
|
459
441
|
constructor(cli) {
|
|
460
442
|
super("@@global@@", "", {}, cli);
|
|
461
443
|
}
|
|
462
|
-
}
|
|
463
|
-
var Command_default = Command;
|
|
444
|
+
}
|
|
464
445
|
|
|
465
|
-
|
|
466
|
-
|
|
446
|
+
var __assign = Object.assign;
|
|
447
|
+
class CAC extends EventEmitter {
|
|
467
448
|
constructor(name = "") {
|
|
468
449
|
super();
|
|
469
450
|
this.name = name;
|
|
@@ -479,7 +460,7 @@ var CAC = class extends EventEmitter {
|
|
|
479
460
|
return this;
|
|
480
461
|
}
|
|
481
462
|
command(rawName, description, config) {
|
|
482
|
-
const command = new
|
|
463
|
+
const command = new Command(rawName, description || "", config, this);
|
|
483
464
|
command.globalCommand = this.globalCommand;
|
|
484
465
|
this.commands.push(command);
|
|
485
466
|
return command;
|
|
@@ -547,10 +528,9 @@ var CAC = class extends EventEmitter {
|
|
|
547
528
|
if (result.matched) {
|
|
548
529
|
shouldParse = false;
|
|
549
530
|
const matchedCommandName = parsed.args.slice(0, result.consumedArgs).join(" ");
|
|
550
|
-
const parsedInfo = {
|
|
551
|
-
...parsed,
|
|
531
|
+
const parsedInfo = __assign(__assign({}, parsed), {
|
|
552
532
|
args: parsed.args.slice(result.consumedArgs)
|
|
553
|
-
};
|
|
533
|
+
});
|
|
554
534
|
this.setParsedInfo(parsedInfo, command, matchedCommandName);
|
|
555
535
|
this.emit(`command:${matchedCommandName}`, command);
|
|
556
536
|
break;
|
|
@@ -601,12 +581,11 @@ var CAC = class extends EventEmitter {
|
|
|
601
581
|
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
602
582
|
argv = argv.slice(0, doubleDashesIndex);
|
|
603
583
|
}
|
|
604
|
-
let parsed = (
|
|
584
|
+
let parsed = mri(argv, mriOptions);
|
|
605
585
|
parsed = Object.keys(parsed).reduce((res, name) => {
|
|
606
|
-
return {
|
|
607
|
-
...res,
|
|
586
|
+
return __assign(__assign({}, res), {
|
|
608
587
|
[camelcaseOptionName(name)]: parsed[name]
|
|
609
|
-
};
|
|
588
|
+
});
|
|
610
589
|
}, {_: []});
|
|
611
590
|
const args = parsed._;
|
|
612
591
|
const options = {
|
|
@@ -658,15 +637,8 @@ var CAC = class extends EventEmitter {
|
|
|
658
637
|
actionArgs.push(options);
|
|
659
638
|
return command.commandAction.apply(this, actionArgs);
|
|
660
639
|
}
|
|
661
|
-
}
|
|
662
|
-
var CAC_default = CAC;
|
|
640
|
+
}
|
|
663
641
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
export {
|
|
668
|
-
CAC_default as CAC,
|
|
669
|
-
Command_default as Command,
|
|
670
|
-
cac,
|
|
671
|
-
src_default as default
|
|
672
|
-
};
|
|
642
|
+
const cac = (name = "") => new CAC(name);
|
|
643
|
+
|
|
644
|
+
export { CAC, Command, cac, cac as default };
|