@bemoje/cli 1.0.2 → 1.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.
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var __decorateClass = (decorators, target, key, kind) => {
30
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
31
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
32
+ if (decorator = decorators[i])
33
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
34
+ if (kind && result) __defProp(target, key, result);
35
+ return result;
36
+ };
37
+ var CommanderHelpAdapter_exports = {};
38
+ __export(CommanderHelpAdapter_exports, {
39
+ CommanderHelpAdapter: () => CommanderHelpAdapter
40
+ });
41
+ module.exports = __toCommonJS(CommanderHelpAdapter_exports);
42
+ var import_Help = require("./Help");
43
+ var import_lazyProp = __toESM(require("./internal/lazyProp"), 1);
44
+ var import_renderHelp = require("./renderHelp");
45
+ const _CommanderHelpAdapter = class _CommanderHelpAdapter {
46
+ constructor(cmd) {
47
+ this.cmd = cmd;
48
+ }
49
+ renderHelp(help = new import_Help.Help()) {
50
+ return (0, import_renderHelp.renderHelp)(this, help);
51
+ }
52
+ get name() {
53
+ return this.cmd.name();
54
+ }
55
+ get aliases() {
56
+ return this.cmd.aliases();
57
+ }
58
+ get summary() {
59
+ const cmdSummary = this.cmd.summary();
60
+ return cmdSummary && cmdSummary.trim() !== "" ? cmdSummary : this.cmd.description().includes("\n") ? this.cmd.description().split("\n")[0] : void 0;
61
+ }
62
+ get description() {
63
+ return this.cmd.description();
64
+ }
65
+ get hidden() {
66
+ return Reflect.get(this.cmd, "_hidden");
67
+ }
68
+ get usage() {
69
+ return this.cmd.usage();
70
+ }
71
+ get group() {
72
+ return this.cmd.helpGroup();
73
+ }
74
+ get commands() {
75
+ return this.cmd.commands.map((c) => new _CommanderHelpAdapter(c));
76
+ }
77
+ get options() {
78
+ return this.cmd.options.map((opt) => ({
79
+ ...opt,
80
+ short: opt.short ?? opt.attributeName()[0],
81
+ long: opt.long ?? opt.attributeName()
82
+ }));
83
+ }
84
+ get arguments() {
85
+ return this.cmd.registeredArguments.map((arg) => ({
86
+ ...arg,
87
+ name: arg.name()
88
+ }));
89
+ }
90
+ get parent() {
91
+ return this.cmd.parent ? new _CommanderHelpAdapter(this.cmd.parent) : null;
92
+ }
93
+ get helpConfiguration() {
94
+ return { ...this.cmd.configureHelp() };
95
+ }
96
+ };
97
+ __decorateClass([
98
+ import_lazyProp.default
99
+ ], _CommanderHelpAdapter.prototype, "summary", 1);
100
+ __decorateClass([
101
+ import_lazyProp.default
102
+ ], _CommanderHelpAdapter.prototype, "commands", 1);
103
+ __decorateClass([
104
+ import_lazyProp.default
105
+ ], _CommanderHelpAdapter.prototype, "options", 1);
106
+ __decorateClass([
107
+ import_lazyProp.default
108
+ ], _CommanderHelpAdapter.prototype, "arguments", 1);
109
+ __decorateClass([
110
+ import_lazyProp.default
111
+ ], _CommanderHelpAdapter.prototype, "parent", 1);
112
+ __decorateClass([
113
+ import_lazyProp.default
114
+ ], _CommanderHelpAdapter.prototype, "helpConfiguration", 1);
115
+ let CommanderHelpAdapter = _CommanderHelpAdapter;
116
+ // Annotate the CommonJS export names for ESM import in node:
117
+ 0 && (module.exports = {
118
+ CommanderHelpAdapter
119
+ });
120
+ //# sourceMappingURL=CommanderHelpAdapter.cjs.map
@@ -0,0 +1,490 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var Help_exports = {};
20
+ __export(Help_exports, {
21
+ Help: () => Help
22
+ });
23
+ module.exports = __toCommonJS(Help_exports);
24
+ class Help {
25
+ /** output helpWidth, long lines are wrapped to fit */
26
+ helpWidth = process.stdout.isTTY ? process.stdout.columns : 80;
27
+ minWidthToWrap = 40;
28
+ sortSubcommands;
29
+ sortOptions;
30
+ showGlobalOptions;
31
+ /**
32
+ * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
33
+ */
34
+ visibleCommands(cmd) {
35
+ const visibleCommands = cmd.commands.filter((cmd2) => !cmd2.hidden);
36
+ if (this.sortSubcommands) {
37
+ visibleCommands.sort((a, b) => {
38
+ return a.name.localeCompare(b.name);
39
+ });
40
+ }
41
+ return visibleCommands;
42
+ }
43
+ /**
44
+ * Compare options for sort.
45
+ */
46
+ compareOptions(a, b) {
47
+ const getSortKey = (option) => {
48
+ return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
49
+ };
50
+ return getSortKey(a).localeCompare(getSortKey(b));
51
+ }
52
+ /**
53
+ * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
54
+ */
55
+ visibleOptions(cmd) {
56
+ const visibleOptions = cmd.options.filter((option) => !option.hidden);
57
+ if (this.sortOptions) {
58
+ visibleOptions.sort(this.compareOptions);
59
+ }
60
+ return visibleOptions;
61
+ }
62
+ /**
63
+ * Get an array of the visible global options. (Not including help.)
64
+ */
65
+ visibleGlobalOptions(cmd) {
66
+ if (!this.showGlobalOptions) return [];
67
+ const globalOptions = [];
68
+ for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
69
+ const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
70
+ globalOptions.push(...visibleOptions);
71
+ }
72
+ if (this.sortOptions) {
73
+ globalOptions.sort(this.compareOptions);
74
+ }
75
+ return globalOptions;
76
+ }
77
+ /**
78
+ * Get an array of the arguments if any have a description.
79
+ */
80
+ visibleArguments(cmd) {
81
+ if (cmd.arguments.find((argument) => argument.description)) {
82
+ return [...cmd.arguments];
83
+ }
84
+ return [];
85
+ }
86
+ /**
87
+ * Get the command term to show in the list of subcommands.
88
+ */
89
+ subcommandTerm(cmd) {
90
+ const args = cmd.arguments.map((arg) => humanReadableArgName(arg)).join(" ");
91
+ return cmd.name + (cmd.aliases[0] ? "|" + cmd.aliases[0] : "") + (cmd.options.length ? " [options]" : "") + // simplistic check for non-help option
92
+ (args ? " " + args : "");
93
+ }
94
+ /**
95
+ * Get the option term to show in the list of options.
96
+ */
97
+ optionTerm(option) {
98
+ return option.flags;
99
+ }
100
+ /**
101
+ * Get the argument term to show in the list of arguments.
102
+ */
103
+ argumentTerm(argument) {
104
+ return argument.name;
105
+ }
106
+ /**
107
+ * Get the longest command term length.
108
+ */
109
+ longestSubcommandTermLength(cmd, helper) {
110
+ return helper.visibleCommands(cmd).reduce((max, command) => {
111
+ return Math.max(max, this.displayWidth(helper.styleSubcommandTerm(helper.subcommandTerm(command))));
112
+ }, 0);
113
+ }
114
+ /**
115
+ * Get the longest option term length.
116
+ */
117
+ longestOptionTermLength(cmd, helper) {
118
+ return helper.visibleOptions(cmd).reduce((max, option) => {
119
+ return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
120
+ }, 0);
121
+ }
122
+ /**
123
+ * Get the longest global option term length.
124
+ */
125
+ longestGlobalOptionTermLength(cmd, helper) {
126
+ return helper.visibleGlobalOptions(cmd).reduce((max, option) => {
127
+ return Math.max(max, this.displayWidth(helper.styleOptionTerm(helper.optionTerm(option))));
128
+ }, 0);
129
+ }
130
+ /**
131
+ * Get the longest argument term length.
132
+ */
133
+ longestArgumentTermLength(cmd, helper) {
134
+ return helper.visibleArguments(cmd).reduce((max, argument) => {
135
+ return Math.max(max, this.displayWidth(helper.styleArgumentTerm(helper.argumentTerm(argument))));
136
+ }, 0);
137
+ }
138
+ /**
139
+ * Get the command usage to be displayed at the top of the built-in help.
140
+ */
141
+ commandUsage(cmd) {
142
+ let cmdName = cmd.name;
143
+ if (cmd.aliases[0]) {
144
+ cmdName = cmdName + "|" + cmd.aliases[0];
145
+ }
146
+ let ancestorCmdNames = "";
147
+ for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
148
+ ancestorCmdNames = ancestorCmd.name + " " + ancestorCmdNames;
149
+ }
150
+ return ancestorCmdNames + cmdName + " " + cmd.usage;
151
+ }
152
+ /**
153
+ * Get the description for the command.
154
+ */
155
+ commandDescription(cmd) {
156
+ return cmd.description;
157
+ }
158
+ /**
159
+ * Get the subcommand summary to show in the list of subcommands.
160
+ * (Fallback to description for backwards compatibility.)
161
+ */
162
+ subcommandDescription(cmd) {
163
+ return cmd.summary || cmd.description;
164
+ }
165
+ /**
166
+ * Get the option description to show in the list of options.
167
+ */
168
+ optionDescription(option) {
169
+ const extraInfo = [];
170
+ if (option.choices) {
171
+ extraInfo.push(
172
+ // use stringify to match the display of the default value
173
+ `choices: ${option.choices.map((choice) => String(choice)).join(", ")}`
174
+ );
175
+ }
176
+ if (option.defaultValue !== void 0) {
177
+ const boolean = !option.required && !option.optional && !option.negate;
178
+ const showDefault = option.required || option.optional || boolean && typeof option.defaultValue === "boolean";
179
+ if (showDefault) {
180
+ extraInfo.push(`default: ${option.defaultValueDescription || String(option.defaultValue)}`);
181
+ }
182
+ }
183
+ if (option.env !== void 0) {
184
+ extraInfo.push(`env: ${option.env}`);
185
+ }
186
+ if (extraInfo.length > 0) {
187
+ const extraDescription = `(${extraInfo.join(", ")})`;
188
+ if (option.description) {
189
+ return `${option.description} ${extraDescription}`;
190
+ }
191
+ return extraDescription;
192
+ }
193
+ return option.description;
194
+ }
195
+ /**
196
+ * Get the argument description to show in the list of arguments.
197
+ */
198
+ argumentDescription(argument) {
199
+ const extraInfo = [];
200
+ if (argument.choices) {
201
+ extraInfo.push(
202
+ // use stringify to match the display of the default value
203
+ `choices: ${argument.choices.map((choice) => String(choice)).join(", ")}`
204
+ );
205
+ }
206
+ if (argument.defaultValue !== void 0) {
207
+ extraInfo.push(`default: ${argument.defaultValueDescription || String(argument.defaultValue)}`);
208
+ }
209
+ if (extraInfo.length > 0) {
210
+ const extraDescription = `(${extraInfo.join(", ")})`;
211
+ if (argument.description) {
212
+ return `${argument.description} ${extraDescription}`;
213
+ }
214
+ return extraDescription;
215
+ }
216
+ return argument.description;
217
+ }
218
+ /**
219
+ * Format a list of items, given a heading and an array of formatted items.
220
+ */
221
+ formatItemList(heading, items, helper) {
222
+ if (items.length === 0) return [];
223
+ return [helper.styleTitle(heading), ...items, ""];
224
+ }
225
+ /**
226
+ * Group items by their help group heading.
227
+ */
228
+ groupItems(unsortedItems, visibleItems, getGroup) {
229
+ const result = /* @__PURE__ */ new Map();
230
+ unsortedItems.forEach((item) => {
231
+ const group = getGroup(item);
232
+ if (!result.has(group)) result.set(group, []);
233
+ });
234
+ visibleItems.forEach((item) => {
235
+ const group = getGroup(item);
236
+ if (!result.has(group)) {
237
+ result.set(group, []);
238
+ }
239
+ result.get(group).push(item);
240
+ });
241
+ return result;
242
+ }
243
+ /**
244
+ * Generate the built-in help text.
245
+ */
246
+ formatHelp(cmd, helper) {
247
+ const termWidth = helper.padWidth(cmd, helper);
248
+ const helpWidth = helper.helpWidth;
249
+ function callFormatItem(term, description) {
250
+ return helper.formatItem(term, termWidth, description, helper);
251
+ }
252
+ let output = [`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`, ""];
253
+ const commandDescription = helper.commandDescription(cmd);
254
+ if (commandDescription.length > 0) {
255
+ output = output.concat([helper.boxWrap(helper.styleCommandDescription(commandDescription), helpWidth), ""]);
256
+ }
257
+ const argumentList = helper.visibleArguments(cmd).map((argument) => {
258
+ return callFormatItem(
259
+ helper.styleArgumentTerm(helper.argumentTerm(argument)),
260
+ helper.styleArgumentDescription(helper.argumentDescription(argument))
261
+ );
262
+ });
263
+ output = output.concat(this.formatItemList("Arguments:", argumentList, helper));
264
+ const optionGroups = this.groupItems(
265
+ cmd.options,
266
+ helper.visibleOptions(cmd),
267
+ (option) => option.group ?? "Options:"
268
+ );
269
+ optionGroups.forEach((options, group) => {
270
+ const optionList = options.map((option) => {
271
+ return callFormatItem(
272
+ helper.styleOptionTerm(helper.optionTerm(option)),
273
+ helper.styleOptionDescription(helper.optionDescription(option))
274
+ );
275
+ });
276
+ output = output.concat(this.formatItemList(group, optionList, helper));
277
+ });
278
+ if (helper.showGlobalOptions) {
279
+ const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
280
+ return callFormatItem(
281
+ helper.styleOptionTerm(helper.optionTerm(option)),
282
+ helper.styleOptionDescription(helper.optionDescription(option))
283
+ );
284
+ });
285
+ output = output.concat(this.formatItemList("Global Options:", globalOptionList, helper));
286
+ }
287
+ const commandGroups = this.groupItems(
288
+ cmd.commands,
289
+ helper.visibleCommands(cmd),
290
+ (sub) => sub.group || "Commands:"
291
+ );
292
+ commandGroups.forEach((commands, group) => {
293
+ const commandList = commands.map((sub) => {
294
+ return callFormatItem(
295
+ helper.styleSubcommandTerm(helper.subcommandTerm(sub)),
296
+ helper.styleSubcommandDescription(helper.subcommandDescription(sub))
297
+ );
298
+ });
299
+ output = output.concat(this.formatItemList(group, commandList, helper));
300
+ });
301
+ return output.join("\n");
302
+ }
303
+ /**
304
+ * Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations.
305
+ */
306
+ displayWidth(str) {
307
+ return stripColor(str).length;
308
+ }
309
+ /**
310
+ * Style the title for displaying in the help. Called with 'Usage:', 'Options:', etc.
311
+ */
312
+ styleTitle(str) {
313
+ return str;
314
+ }
315
+ /**
316
+ * Style the usage line for displaying in the help. Applies specific styling to different parts like options, commands, and arguments.
317
+ */
318
+ styleUsage(str) {
319
+ return str.split(" ").map((word) => {
320
+ if (word === "[options]") return this.styleOptionText(word);
321
+ if (word === "[command]") return this.styleSubcommandText(word);
322
+ if (word[0] === "[" || word[0] === "<") return this.styleArgumentText(word);
323
+ return this.styleCommandText(word);
324
+ }).join(" ");
325
+ }
326
+ /**
327
+ * Style command descriptions for display in help output.
328
+ */
329
+ styleCommandDescription(str) {
330
+ return this.styleDescriptionText(str);
331
+ }
332
+ /**
333
+ * Style option descriptions for display in help output.
334
+ */
335
+ styleOptionDescription(str) {
336
+ return this.styleDescriptionText(str);
337
+ }
338
+ /**
339
+ * Style subcommand descriptions for display in help output.
340
+ */
341
+ styleSubcommandDescription(str) {
342
+ return this.styleDescriptionText(str);
343
+ }
344
+ /**
345
+ * Style argument descriptions for display in help output.
346
+ */
347
+ styleArgumentDescription(str) {
348
+ return this.styleDescriptionText(str);
349
+ }
350
+ /**
351
+ * Base style used by descriptions. Override in subclass to apply custom formatting.
352
+ */
353
+ styleDescriptionText(str) {
354
+ return str;
355
+ }
356
+ /**
357
+ * Style option terms (flags) for display in help output.
358
+ */
359
+ styleOptionTerm(str) {
360
+ return this.styleOptionText(str);
361
+ }
362
+ /**
363
+ * Style subcommand terms for display in help output. Applies specific styling to different parts like options and arguments.
364
+ */
365
+ styleSubcommandTerm(str) {
366
+ return str.split(" ").map((word) => {
367
+ if (word === "[options]") return this.styleOptionText(word);
368
+ if (word[0] === "[" || word[0] === "<") return this.styleArgumentText(word);
369
+ return this.styleSubcommandText(word);
370
+ }).join(" ");
371
+ }
372
+ /**
373
+ * Style argument terms for display in help output.
374
+ */
375
+ styleArgumentTerm(str) {
376
+ return this.styleArgumentText(str);
377
+ }
378
+ /**
379
+ * Base style used in terms and usage for options. Override in subclass to apply custom formatting.
380
+ */
381
+ styleOptionText(str) {
382
+ return str;
383
+ }
384
+ /**
385
+ * Base style used in terms and usage for arguments. Override in subclass to apply custom formatting.
386
+ */
387
+ styleArgumentText(str) {
388
+ return str;
389
+ }
390
+ /**
391
+ * Base style used in terms and usage for subcommands. Override in subclass to apply custom formatting.
392
+ */
393
+ styleSubcommandText(str) {
394
+ return str;
395
+ }
396
+ /**
397
+ * Base style used in terms and usage for commands. Override in subclass to apply custom formatting.
398
+ */
399
+ styleCommandText(str) {
400
+ return str;
401
+ }
402
+ /**
403
+ * Calculate the pad width from the maximum term length.
404
+ */
405
+ padWidth(cmd, helper) {
406
+ return Math.max(
407
+ helper.longestOptionTermLength(cmd, helper),
408
+ helper.longestGlobalOptionTermLength(cmd, helper),
409
+ helper.longestSubcommandTermLength(cmd, helper),
410
+ helper.longestArgumentTermLength(cmd, helper)
411
+ );
412
+ }
413
+ /**
414
+ * Detect manually wrapped and indented strings by checking for line break followed by whitespace.
415
+ */
416
+ preformatted(str) {
417
+ return /\n[^\S\r\n]/.test(str);
418
+ }
419
+ /**
420
+ * Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
421
+ *
422
+ * So "TTT", 5, "DDD DDDD DD DDD" might be formatted for this.helpWidth=17 like so:
423
+ * TTT DDD DDDD
424
+ * DD DDD
425
+ */
426
+ formatItem(term, termWidth, description, helper) {
427
+ const itemIndent = 2;
428
+ const itemIndentStr = " ".repeat(itemIndent);
429
+ if (!description) return itemIndentStr + term;
430
+ const paddedTerm = term.padEnd(termWidth + term.length - helper.displayWidth(term));
431
+ const spacerWidth = 2;
432
+ const helpWidth = this.helpWidth;
433
+ const remainingWidth = helpWidth - termWidth - spacerWidth - itemIndent;
434
+ let formattedDescription;
435
+ if (remainingWidth < this.minWidthToWrap || helper.preformatted(description)) {
436
+ formattedDescription = description;
437
+ } else {
438
+ const wrappedDescription = helper.boxWrap(description, remainingWidth);
439
+ formattedDescription = wrappedDescription.replace(/\n/g, "\n" + " ".repeat(termWidth + spacerWidth));
440
+ }
441
+ return itemIndentStr + paddedTerm + " ".repeat(spacerWidth) + formattedDescription.replace(/\n/g, `
442
+ ${itemIndentStr}`);
443
+ }
444
+ /**
445
+ * Wrap a string at whitespace, preserving existing line breaks.
446
+ * Wrapping is skipped if the width is less than `minWidthToWrap`.
447
+ */
448
+ boxWrap(str, width) {
449
+ if (width < this.minWidthToWrap) return str;
450
+ const rawLines = str.split(/\r\n|\n/);
451
+ const chunkPattern = /[\s]*[^\s]+/g;
452
+ const wrappedLines = [];
453
+ rawLines.forEach((line) => {
454
+ const chunks = line.match(chunkPattern);
455
+ if (chunks === null) {
456
+ wrappedLines.push("");
457
+ return;
458
+ }
459
+ let sumChunks = [chunks.shift()];
460
+ let sumWidth = this.displayWidth(sumChunks[0]);
461
+ chunks.forEach((chunk) => {
462
+ const visibleWidth = this.displayWidth(chunk);
463
+ if (sumWidth + visibleWidth <= width) {
464
+ sumChunks.push(chunk);
465
+ sumWidth += visibleWidth;
466
+ return;
467
+ }
468
+ wrappedLines.push(sumChunks.join(""));
469
+ const nextChunk = chunk.trimStart();
470
+ sumChunks = [nextChunk];
471
+ sumWidth = this.displayWidth(nextChunk);
472
+ });
473
+ wrappedLines.push(sumChunks.join(""));
474
+ });
475
+ return wrappedLines.join("\n");
476
+ }
477
+ }
478
+ function stripColor(str) {
479
+ const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
480
+ return str.replace(sgrPattern, "");
481
+ }
482
+ function humanReadableArgName(arg) {
483
+ const nameOutput = arg.name + (arg.variadic === true ? "..." : "");
484
+ return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
485
+ }
486
+ // Annotate the CommonJS export names for ESM import in node:
487
+ 0 && (module.exports = {
488
+ Help
489
+ });
490
+ //# sourceMappingURL=Help.cjs.map
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var lazyProp_exports = {};
20
+ __export(lazyProp_exports, {
21
+ default: () => lazyProp
22
+ });
23
+ module.exports = __toCommonJS(lazyProp_exports);
24
+ function lazyProp(target, key, descriptor) {
25
+ const orig = descriptor.get;
26
+ if (typeof orig !== "function") {
27
+ throw new Error('"get" not a function');
28
+ }
29
+ descriptor.get = function() {
30
+ const value = orig.call(this);
31
+ Object.defineProperty(this, key, {
32
+ enumerable: false,
33
+ writable: false,
34
+ configurable: true,
35
+ value
36
+ });
37
+ return value;
38
+ };
39
+ return descriptor;
40
+ }
41
+ //# sourceMappingURL=lazyProp.cjs.map
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var renderHelp_exports = {};
20
+ __export(renderHelp_exports, {
21
+ renderHelp: () => renderHelp
22
+ });
23
+ module.exports = __toCommonJS(renderHelp_exports);
24
+ var import_Help = require("./Help");
25
+ function renderHelp(cmd, help = new import_Help.Help()) {
26
+ const helper = Object.assign(help, cmd.helpConfiguration);
27
+ return helper.formatHelp(cmd, helper);
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ renderHelp
32
+ });
33
+ //# sourceMappingURL=renderHelp.cjs.map
@@ -3,4 +3,4 @@ export * from "./lib/CommandHelpAdapter";
3
3
  export * from "./lib/CommanderHelpAdapter";
4
4
  export * from "./lib/Help";
5
5
  export * from "./lib/renderHelp";
6
- //# sourceMappingURL=index.js.map
6
+ //# sourceMappingURL=index.mjs.map