@bemoje/cli 1.0.2 → 1.0.3
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/index.js +30 -5
- package/lib/Command.js +58 -40
- package/lib/CommandHelpAdapter.js +44 -14
- package/lib/CommanderHelpAdapter.js +45 -15
- package/lib/Help.js +34 -21
- package/lib/internal/lazyProp.js +22 -5
- package/lib/renderHelp.js +27 -6
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
|
18
|
+
__reExport(src_exports, require("./lib/Command"), module.exports);
|
|
19
|
+
__reExport(src_exports, require("./lib/CommandHelpAdapter"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./lib/CommanderHelpAdapter"), module.exports);
|
|
21
|
+
__reExport(src_exports, require("./lib/Help"), module.exports);
|
|
22
|
+
__reExport(src_exports, require("./lib/renderHelp"), module.exports);
|
|
23
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
24
|
+
0 && (module.exports = {
|
|
25
|
+
...require("./lib/Command"),
|
|
26
|
+
...require("./lib/CommandHelpAdapter"),
|
|
27
|
+
...require("./lib/CommanderHelpAdapter"),
|
|
28
|
+
...require("./lib/Help"),
|
|
29
|
+
...require("./lib/renderHelp")
|
|
30
|
+
});
|
|
6
31
|
//# sourceMappingURL=index.js.map
|
package/lib/Command.js
CHANGED
|
@@ -1,35 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 Command_exports = {};
|
|
20
|
+
__export(Command_exports, {
|
|
21
|
+
Command: () => Command
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(Command_exports);
|
|
24
|
+
var import_node_util = require("node:util");
|
|
25
|
+
var import_CommandHelpAdapter = require("./CommandHelpAdapter");
|
|
26
|
+
class Command {
|
|
27
|
+
/** Command name used for invocation */
|
|
28
|
+
name;
|
|
29
|
+
/** Optional version string */
|
|
30
|
+
version;
|
|
31
|
+
/** Alternative names for this command */
|
|
32
|
+
aliases;
|
|
33
|
+
/** Brief single-line description */
|
|
34
|
+
summary;
|
|
35
|
+
/** Full command description */
|
|
36
|
+
description;
|
|
37
|
+
/** Whether command should be hidden from help */
|
|
38
|
+
hidden;
|
|
39
|
+
/** Group name for organizing commands in help */
|
|
40
|
+
group;
|
|
41
|
+
/** Parent command if this is a subcommand */
|
|
42
|
+
parent;
|
|
43
|
+
/** Child subcommands */
|
|
44
|
+
commands;
|
|
45
|
+
/** Positional arguments */
|
|
46
|
+
arguments;
|
|
47
|
+
/** Named options/flags */
|
|
48
|
+
options;
|
|
49
|
+
/** Help system configuration */
|
|
50
|
+
helpConfiguration;
|
|
8
51
|
constructor(name = "", parent = null) {
|
|
9
|
-
/** Command name used for invocation */
|
|
10
|
-
__publicField(this, "name");
|
|
11
|
-
/** Optional version string */
|
|
12
|
-
__publicField(this, "version");
|
|
13
|
-
/** Alternative names for this command */
|
|
14
|
-
__publicField(this, "aliases");
|
|
15
|
-
/** Brief single-line description */
|
|
16
|
-
__publicField(this, "summary");
|
|
17
|
-
/** Full command description */
|
|
18
|
-
__publicField(this, "description");
|
|
19
|
-
/** Whether command should be hidden from help */
|
|
20
|
-
__publicField(this, "hidden");
|
|
21
|
-
/** Group name for organizing commands in help */
|
|
22
|
-
__publicField(this, "group");
|
|
23
|
-
/** Parent command if this is a subcommand */
|
|
24
|
-
__publicField(this, "parent");
|
|
25
|
-
/** Child subcommands */
|
|
26
|
-
__publicField(this, "commands");
|
|
27
|
-
/** Positional arguments */
|
|
28
|
-
__publicField(this, "arguments");
|
|
29
|
-
/** Named options/flags */
|
|
30
|
-
__publicField(this, "options");
|
|
31
|
-
/** Help system configuration */
|
|
32
|
-
__publicField(this, "helpConfiguration");
|
|
33
52
|
this.name = name;
|
|
34
53
|
this.parent = parent;
|
|
35
54
|
this.aliases = [];
|
|
@@ -44,7 +63,7 @@ const _Command = class _Command {
|
|
|
44
63
|
setState(state) {
|
|
45
64
|
Object.assign(this, state);
|
|
46
65
|
if (state.commands) {
|
|
47
|
-
state.commands = state.commands.map((cmd) => new
|
|
66
|
+
state.commands = state.commands.map((cmd) => new Command(cmd.name, this).setState(cmd));
|
|
48
67
|
}
|
|
49
68
|
return this;
|
|
50
69
|
}
|
|
@@ -127,7 +146,7 @@ const _Command = class _Command {
|
|
|
127
146
|
}
|
|
128
147
|
/** Creates and adds a subcommand */
|
|
129
148
|
subcommand(name) {
|
|
130
|
-
const sub = new
|
|
149
|
+
const sub = new Command(name, this);
|
|
131
150
|
this.commands.push(sub);
|
|
132
151
|
return sub;
|
|
133
152
|
}
|
|
@@ -268,7 +287,7 @@ const _Command = class _Command {
|
|
|
268
287
|
* ```
|
|
269
288
|
*/
|
|
270
289
|
parse(argv = process.argv.slice(2), globalOptions = []) {
|
|
271
|
-
const maybeSubArg = parseArgs({
|
|
290
|
+
const maybeSubArg = (0, import_node_util.parseArgs)({
|
|
272
291
|
args: argv,
|
|
273
292
|
allowPositionals: true,
|
|
274
293
|
tokens: false,
|
|
@@ -282,7 +301,7 @@ const _Command = class _Command {
|
|
|
282
301
|
[...globalOptions, ...this.options]
|
|
283
302
|
);
|
|
284
303
|
}
|
|
285
|
-
const parsed = parseArgs({
|
|
304
|
+
const parsed = (0, import_node_util.parseArgs)({
|
|
286
305
|
args: argv,
|
|
287
306
|
options: Object.fromEntries(
|
|
288
307
|
[...globalOptions, ...this.options].map((o) => {
|
|
@@ -420,16 +439,15 @@ const _Command = class _Command {
|
|
|
420
439
|
}
|
|
421
440
|
/** Returns a view that is compliant with the CommandHelp interface */
|
|
422
441
|
createHelpAdapter() {
|
|
423
|
-
return new CommandHelpAdapter(this);
|
|
442
|
+
return new import_CommandHelpAdapter.CommandHelpAdapter(this);
|
|
424
443
|
}
|
|
425
444
|
/** Renders formatted help text using provided help definition */
|
|
426
445
|
renderHelp(help) {
|
|
427
446
|
return this.createHelpAdapter().renderHelp(help);
|
|
428
447
|
}
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
export {
|
|
448
|
+
}
|
|
449
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
450
|
+
0 && (module.exports = {
|
|
433
451
|
Command
|
|
434
|
-
};
|
|
452
|
+
});
|
|
435
453
|
//# sourceMappingURL=Command.js.map
|
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
2
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var
|
|
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);
|
|
4
29
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
30
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
31
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -9,15 +34,20 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
9
34
|
if (kind && result) __defProp(target, key, result);
|
|
10
35
|
return result;
|
|
11
36
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
37
|
+
var CommandHelpAdapter_exports = {};
|
|
38
|
+
__export(CommandHelpAdapter_exports, {
|
|
39
|
+
CommandHelpAdapter: () => CommandHelpAdapter
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(CommandHelpAdapter_exports);
|
|
42
|
+
var import_lazyProp = __toESM(require("./internal/lazyProp"), 1);
|
|
43
|
+
var import_Help = require("./Help");
|
|
44
|
+
var import_renderHelp = require("./renderHelp");
|
|
15
45
|
const _CommandHelpAdapter = class _CommandHelpAdapter {
|
|
16
46
|
constructor(cmd) {
|
|
17
47
|
this.cmd = cmd;
|
|
18
48
|
}
|
|
19
|
-
renderHelp(help = new Help()) {
|
|
20
|
-
return renderHelp(this, help);
|
|
49
|
+
renderHelp(help = new import_Help.Help()) {
|
|
50
|
+
return (0, import_renderHelp.renderHelp)(this, help);
|
|
21
51
|
}
|
|
22
52
|
get name() {
|
|
23
53
|
return this.cmd.name;
|
|
@@ -77,24 +107,24 @@ const _CommandHelpAdapter = class _CommandHelpAdapter {
|
|
|
77
107
|
return opt.type === "boolean" ? flags : opt.required ? opt.multiple ? flags + ` <${opt.argName}...>` : flags + ` <${opt.argName}>` : opt.multiple ? flags + ` [${opt.argName}...]` : flags + ` [${opt.argName}]`;
|
|
78
108
|
}
|
|
79
109
|
};
|
|
80
|
-
__name(_CommandHelpAdapter, "CommandHelpAdapter");
|
|
81
110
|
__decorateClass([
|
|
82
|
-
|
|
111
|
+
import_lazyProp.default
|
|
83
112
|
], _CommandHelpAdapter.prototype, "usage", 1);
|
|
84
113
|
__decorateClass([
|
|
85
|
-
|
|
114
|
+
import_lazyProp.default
|
|
86
115
|
], _CommandHelpAdapter.prototype, "commands", 1);
|
|
87
116
|
__decorateClass([
|
|
88
|
-
|
|
117
|
+
import_lazyProp.default
|
|
89
118
|
], _CommandHelpAdapter.prototype, "arguments", 1);
|
|
90
119
|
__decorateClass([
|
|
91
|
-
|
|
120
|
+
import_lazyProp.default
|
|
92
121
|
], _CommandHelpAdapter.prototype, "parent", 1);
|
|
93
122
|
__decorateClass([
|
|
94
|
-
|
|
123
|
+
import_lazyProp.default
|
|
95
124
|
], _CommandHelpAdapter.prototype, "helpConfiguration", 1);
|
|
96
125
|
let CommandHelpAdapter = _CommandHelpAdapter;
|
|
97
|
-
export
|
|
126
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
127
|
+
0 && (module.exports = {
|
|
98
128
|
CommandHelpAdapter
|
|
99
|
-
};
|
|
129
|
+
});
|
|
100
130
|
//# sourceMappingURL=CommandHelpAdapter.js.map
|
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
2
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var
|
|
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);
|
|
4
29
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
30
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
31
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -9,15 +34,20 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
9
34
|
if (kind && result) __defProp(target, key, result);
|
|
10
35
|
return result;
|
|
11
36
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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");
|
|
15
45
|
const _CommanderHelpAdapter = class _CommanderHelpAdapter {
|
|
16
46
|
constructor(cmd) {
|
|
17
47
|
this.cmd = cmd;
|
|
18
48
|
}
|
|
19
|
-
renderHelp(help = new Help()) {
|
|
20
|
-
return renderHelp(this, help);
|
|
49
|
+
renderHelp(help = new import_Help.Help()) {
|
|
50
|
+
return (0, import_renderHelp.renderHelp)(this, help);
|
|
21
51
|
}
|
|
22
52
|
get name() {
|
|
23
53
|
return this.cmd.name();
|
|
@@ -64,27 +94,27 @@ const _CommanderHelpAdapter = class _CommanderHelpAdapter {
|
|
|
64
94
|
return { ...this.cmd.configureHelp() };
|
|
65
95
|
}
|
|
66
96
|
};
|
|
67
|
-
__name(_CommanderHelpAdapter, "CommanderHelpAdapter");
|
|
68
97
|
__decorateClass([
|
|
69
|
-
|
|
98
|
+
import_lazyProp.default
|
|
70
99
|
], _CommanderHelpAdapter.prototype, "summary", 1);
|
|
71
100
|
__decorateClass([
|
|
72
|
-
|
|
101
|
+
import_lazyProp.default
|
|
73
102
|
], _CommanderHelpAdapter.prototype, "commands", 1);
|
|
74
103
|
__decorateClass([
|
|
75
|
-
|
|
104
|
+
import_lazyProp.default
|
|
76
105
|
], _CommanderHelpAdapter.prototype, "options", 1);
|
|
77
106
|
__decorateClass([
|
|
78
|
-
|
|
107
|
+
import_lazyProp.default
|
|
79
108
|
], _CommanderHelpAdapter.prototype, "arguments", 1);
|
|
80
109
|
__decorateClass([
|
|
81
|
-
|
|
110
|
+
import_lazyProp.default
|
|
82
111
|
], _CommanderHelpAdapter.prototype, "parent", 1);
|
|
83
112
|
__decorateClass([
|
|
84
|
-
|
|
113
|
+
import_lazyProp.default
|
|
85
114
|
], _CommanderHelpAdapter.prototype, "helpConfiguration", 1);
|
|
86
115
|
let CommanderHelpAdapter = _CommanderHelpAdapter;
|
|
87
|
-
export
|
|
116
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
117
|
+
0 && (module.exports = {
|
|
88
118
|
CommanderHelpAdapter
|
|
89
|
-
};
|
|
119
|
+
});
|
|
90
120
|
//# sourceMappingURL=CommanderHelpAdapter.js.map
|
package/lib/Help.js
CHANGED
|
@@ -1,16 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 });
|
|
13
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;
|
|
14
31
|
/**
|
|
15
32
|
* Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
|
|
16
33
|
*/
|
|
@@ -27,9 +44,9 @@ const _Help = class _Help {
|
|
|
27
44
|
* Compare options for sort.
|
|
28
45
|
*/
|
|
29
46
|
compareOptions(a, b) {
|
|
30
|
-
const getSortKey =
|
|
47
|
+
const getSortKey = (option) => {
|
|
31
48
|
return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, "");
|
|
32
|
-
}
|
|
49
|
+
};
|
|
33
50
|
return getSortKey(a).localeCompare(getSortKey(b));
|
|
34
51
|
}
|
|
35
52
|
/**
|
|
@@ -232,7 +249,6 @@ const _Help = class _Help {
|
|
|
232
249
|
function callFormatItem(term, description) {
|
|
233
250
|
return helper.formatItem(term, termWidth, description, helper);
|
|
234
251
|
}
|
|
235
|
-
__name(callFormatItem, "callFormatItem");
|
|
236
252
|
let output = [`${helper.styleTitle("Usage:")} ${helper.styleUsage(helper.commandUsage(cmd))}`, ""];
|
|
237
253
|
const commandDescription = helper.commandDescription(cmd);
|
|
238
254
|
if (commandDescription.length > 0) {
|
|
@@ -458,20 +474,17 @@ ${itemIndentStr}`);
|
|
|
458
474
|
});
|
|
459
475
|
return wrappedLines.join("\n");
|
|
460
476
|
}
|
|
461
|
-
}
|
|
462
|
-
__name(_Help, "Help");
|
|
463
|
-
let Help = _Help;
|
|
477
|
+
}
|
|
464
478
|
function stripColor(str) {
|
|
465
479
|
const sgrPattern = /\x1b\[\d*(;\d*)*m/g;
|
|
466
480
|
return str.replace(sgrPattern, "");
|
|
467
481
|
}
|
|
468
|
-
__name(stripColor, "stripColor");
|
|
469
482
|
function humanReadableArgName(arg) {
|
|
470
483
|
const nameOutput = arg.name + (arg.variadic === true ? "..." : "");
|
|
471
484
|
return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
|
|
472
485
|
}
|
|
473
|
-
|
|
474
|
-
|
|
486
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
487
|
+
0 && (module.exports = {
|
|
475
488
|
Help
|
|
476
|
-
};
|
|
489
|
+
});
|
|
477
490
|
//# sourceMappingURL=Help.js.map
|
package/lib/internal/lazyProp.js
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
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);
|
|
3
24
|
function lazyProp(target, key, descriptor) {
|
|
4
25
|
const orig = descriptor.get;
|
|
5
26
|
if (typeof orig !== "function") {
|
|
@@ -17,8 +38,4 @@ function lazyProp(target, key, descriptor) {
|
|
|
17
38
|
};
|
|
18
39
|
return descriptor;
|
|
19
40
|
}
|
|
20
|
-
__name(lazyProp, "lazyProp");
|
|
21
|
-
export {
|
|
22
|
-
lazyProp as default
|
|
23
|
-
};
|
|
24
41
|
//# sourceMappingURL=lazyProp.js.map
|
package/lib/renderHelp.js
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
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()) {
|
|
5
26
|
const helper = Object.assign(help, cmd.helpConfiguration);
|
|
6
27
|
return helper.formatHelp(cmd, helper);
|
|
7
28
|
}
|
|
8
|
-
|
|
9
|
-
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
10
31
|
renderHelp
|
|
11
|
-
};
|
|
32
|
+
});
|
|
12
33
|
//# sourceMappingURL=renderHelp.js.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/cli",
|
|
3
3
|
"description": "A type-safe CLI builder focused on command composition and help generation without execution coupling. Parse arguments, generate help, and integrate with existing CLI frameworks through a clean, fluent API.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"type": "
|
|
7
|
+
"type": "commonjs",
|
|
8
8
|
"module": "./index.js",
|
|
9
9
|
"main": "./index.js",
|
|
10
10
|
"exports": {
|