@bemoje/cli 1.0.6 → 1.1.0

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.
@@ -1,157 +0,0 @@
1
- import { Command, ArgumentDescriptor, ArgumentUsage, OptionDescriptor, OptionUsage } from './Command';
2
- import { type ICommandHelp, type IHelp } from './Help';
3
- /**
4
- * Adapter for @see Command instances that implements the @see ICommandHelp interface required by the Help system.
5
- * Used internally by the @see Command.prototype.renderHelp method.
6
- */
7
- export declare class CommandHelpAdapter implements ICommandHelp {
8
- cmd: Command;
9
- constructor(cmd: Command);
10
- renderHelp(help?: IHelp): string;
11
- get name(): string;
12
- get aliases(): string[];
13
- get summary(): string;
14
- get description(): string;
15
- get hidden(): boolean;
16
- get usage(): string;
17
- get group(): string;
18
- get commands(): ICommandHelp[];
19
- get options(): ({
20
- flags: string;
21
- long: string;
22
- optional: boolean;
23
- negate: boolean;
24
- variadic: boolean;
25
- type: "boolean";
26
- argName?: never;
27
- required: false;
28
- multiple: false;
29
- defaultValue?: boolean;
30
- defaultValueDescription?: string;
31
- short: string;
32
- name: string;
33
- description: string;
34
- env?: string;
35
- hidden?: boolean;
36
- choices?: string[];
37
- group?: string;
38
- } | {
39
- flags: string;
40
- long: string;
41
- optional: boolean;
42
- negate: boolean;
43
- variadic: boolean;
44
- type: "string";
45
- argName: string;
46
- required: true;
47
- multiple: false;
48
- defaultValue?: never;
49
- defaultValueDescription?: never;
50
- short: string;
51
- name: string;
52
- description: string;
53
- env?: string;
54
- hidden?: boolean;
55
- choices?: string[];
56
- group?: string;
57
- } | {
58
- flags: string;
59
- long: string;
60
- optional: boolean;
61
- negate: boolean;
62
- variadic: boolean;
63
- type: "string";
64
- argName: string;
65
- required: false;
66
- multiple: false;
67
- defaultValue?: string;
68
- defaultValueDescription?: string;
69
- short: string;
70
- name: string;
71
- description: string;
72
- env?: string;
73
- hidden?: boolean;
74
- choices?: string[];
75
- group?: string;
76
- } | {
77
- flags: string;
78
- long: string;
79
- optional: boolean;
80
- negate: boolean;
81
- variadic: boolean;
82
- type: "string";
83
- argName: string;
84
- required: true;
85
- multiple: true;
86
- defaultValue?: never;
87
- defaultValueDescription?: never;
88
- short: string;
89
- name: string;
90
- description: string;
91
- env?: string;
92
- hidden?: boolean;
93
- choices?: string[];
94
- group?: string;
95
- } | {
96
- flags: string;
97
- long: string;
98
- optional: boolean;
99
- negate: boolean;
100
- variadic: boolean;
101
- type: "string";
102
- argName: string;
103
- required: false;
104
- multiple: true;
105
- defaultValue?: string[];
106
- defaultValueDescription?: string;
107
- short: string;
108
- name: string;
109
- description: string;
110
- env?: string;
111
- hidden?: boolean;
112
- choices?: string[];
113
- group?: string;
114
- })[];
115
- get arguments(): ({
116
- variadic: boolean;
117
- multiple: false;
118
- required: true;
119
- defaultValue?: never;
120
- defaultValueDescription?: never;
121
- name: string;
122
- description: string;
123
- choices?: string[];
124
- } | {
125
- variadic: boolean;
126
- required: false;
127
- multiple: false;
128
- defaultValue?: string;
129
- defaultValueDescription?: string;
130
- name: string;
131
- description: string;
132
- choices?: string[];
133
- } | {
134
- variadic: boolean;
135
- required: true;
136
- multiple: true;
137
- defaultValue?: never;
138
- defaultValueDescription?: never;
139
- name: string;
140
- description: string;
141
- choices?: string[];
142
- } | {
143
- variadic: boolean;
144
- required: false;
145
- multiple: true;
146
- defaultValue?: string[];
147
- defaultValueDescription?: string;
148
- name: string;
149
- description: string;
150
- choices?: string[];
151
- })[];
152
- get parent(): ICommandHelp | null;
153
- get helpConfiguration(): Partial<IHelp>;
154
- renderArgumentFlags(arg: ArgumentDescriptor): ArgumentUsage;
155
- renderOptionFlags(opt: OptionDescriptor): OptionUsage;
156
- }
157
- //# sourceMappingURL=CommandHelpAdapter.d.ts.map
@@ -1,102 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
- var __decorateClass = (decorators, target, key, kind) => {
5
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
6
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
- if (decorator = decorators[i])
8
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
- if (kind && result) __defProp(target, key, result);
10
- return result;
11
- };
12
- import lazyProp from "./internal/lazyProp.js";
13
- import { Help } from "./Help.js";
14
- import { renderHelp } from "./renderHelp.js";
15
- const _CommandHelpAdapter = class _CommandHelpAdapter {
16
- constructor(cmd) {
17
- this.cmd = cmd;
18
- }
19
- static {
20
- __name(this, "CommandHelpAdapter");
21
- }
22
- renderHelp(help = new Help()) {
23
- return renderHelp(this, help);
24
- }
25
- get name() {
26
- return this.cmd.name;
27
- }
28
- get aliases() {
29
- return this.cmd.aliases;
30
- }
31
- get summary() {
32
- return this.cmd.summary ?? (this.cmd.description.includes("\n") ? this.cmd.description.split("\n")[0] : void 0);
33
- }
34
- get description() {
35
- return this.cmd.description;
36
- }
37
- get hidden() {
38
- return this.cmd.hidden;
39
- }
40
- get usage() {
41
- return [
42
- ...this.cmd.options.length ? ["[options]"] : [],
43
- ...this.cmd.commands.length ? ["[command]"] : [],
44
- ...this.cmd.arguments.map((arg) => this.renderArgumentFlags(arg))
45
- ].join(" ");
46
- }
47
- get group() {
48
- return this.cmd.group;
49
- }
50
- get commands() {
51
- return this.cmd.commands.map((c) => new _CommandHelpAdapter(c));
52
- }
53
- get options() {
54
- return this.cmd.options.map((opt) => ({
55
- ...opt,
56
- flags: this.renderOptionFlags(opt),
57
- long: opt.name,
58
- optional: !opt.required,
59
- negate: false,
60
- variadic: opt.multiple
61
- }));
62
- }
63
- get arguments() {
64
- return this.cmd.arguments.map((arg) => ({
65
- ...arg,
66
- variadic: arg.multiple
67
- }));
68
- }
69
- get parent() {
70
- return this.cmd.parent ? new _CommandHelpAdapter(this.cmd.parent) : null;
71
- }
72
- get helpConfiguration() {
73
- return { ...this.cmd.helpConfiguration };
74
- }
75
- renderArgumentFlags(arg) {
76
- return arg.required ? arg.multiple ? `<${arg.name}...>` : `<${arg.name}>` : arg.multiple ? `[${arg.name}...]` : `[${arg.name}]`;
77
- }
78
- renderOptionFlags(opt) {
79
- const flags = `-${opt.short}, --${opt.name}`;
80
- return opt.type === "boolean" ? flags : opt.required ? opt.multiple ? flags + ` <${opt.argName}...>` : flags + ` <${opt.argName}>` : opt.multiple ? flags + ` [${opt.argName}...]` : flags + ` [${opt.argName}]`;
81
- }
82
- };
83
- __decorateClass([
84
- lazyProp
85
- ], _CommandHelpAdapter.prototype, "usage", 1);
86
- __decorateClass([
87
- lazyProp
88
- ], _CommandHelpAdapter.prototype, "commands", 1);
89
- __decorateClass([
90
- lazyProp
91
- ], _CommandHelpAdapter.prototype, "arguments", 1);
92
- __decorateClass([
93
- lazyProp
94
- ], _CommandHelpAdapter.prototype, "parent", 1);
95
- __decorateClass([
96
- lazyProp
97
- ], _CommandHelpAdapter.prototype, "helpConfiguration", 1);
98
- let CommandHelpAdapter = _CommandHelpAdapter;
99
- export {
100
- CommandHelpAdapter
101
- };
102
- //# sourceMappingURL=CommandHelpAdapter.js.map
@@ -1,56 +0,0 @@
1
- import type { Command as Commander } from 'commander';
2
- import { type ICommandHelp, type IHelp } from './Help';
3
- /**
4
- * Adapter for commander.js @see Command instances that implements the @see ICommandHelp interface required by the Help system.
5
- *
6
- * @example ```ts
7
- * import { Command } from 'commander'
8
- * const cmd = new Command('myapp')
9
- * new CommanderHelpAdapter(cmd).renderHelp()
10
- * ```
11
- */
12
- export declare class CommanderHelpAdapter implements ICommandHelp {
13
- cmd: Commander;
14
- constructor(cmd: Commander);
15
- renderHelp(help?: IHelp): string;
16
- get name(): string;
17
- get aliases(): string[];
18
- get summary(): string;
19
- get description(): string;
20
- get hidden(): any;
21
- get usage(): string;
22
- get group(): string;
23
- get commands(): CommanderHelpAdapter[];
24
- get options(): {
25
- short: string;
26
- long: string;
27
- flags: string;
28
- description: string;
29
- required: boolean;
30
- optional: boolean;
31
- variadic: boolean;
32
- mandatory: boolean;
33
- negate: boolean;
34
- defaultValue?: any;
35
- defaultValueDescription?: string;
36
- presetArg?: unknown;
37
- envVar?: string;
38
- parseArg?: <T>(value: string, previous: T) => T;
39
- hidden: boolean;
40
- argChoices?: string[];
41
- helpGroupHeading?: string;
42
- }[];
43
- get arguments(): {
44
- name: string;
45
- description: string;
46
- required: boolean;
47
- variadic: boolean;
48
- defaultValue?: any;
49
- defaultValueDescription?: string;
50
- parseArg?: <T>(value: string, previous: T) => T;
51
- argChoices?: string[];
52
- }[];
53
- get parent(): ICommandHelp | null;
54
- get helpConfiguration(): Partial<IHelp>;
55
- }
56
- //# sourceMappingURL=CommanderHelpAdapter.d.ts.map
@@ -1,92 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
- var __decorateClass = (decorators, target, key, kind) => {
5
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
6
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
- if (decorator = decorators[i])
8
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
- if (kind && result) __defProp(target, key, result);
10
- return result;
11
- };
12
- import { Help } from "./Help.js";
13
- import lazyProp from "./internal/lazyProp.js";
14
- import { renderHelp } from "./renderHelp.js";
15
- const _CommanderHelpAdapter = class _CommanderHelpAdapter {
16
- constructor(cmd) {
17
- this.cmd = cmd;
18
- }
19
- static {
20
- __name(this, "CommanderHelpAdapter");
21
- }
22
- renderHelp(help = new Help()) {
23
- return renderHelp(this, help);
24
- }
25
- get name() {
26
- return this.cmd.name();
27
- }
28
- get aliases() {
29
- return this.cmd.aliases();
30
- }
31
- get summary() {
32
- const cmdSummary = this.cmd.summary();
33
- return cmdSummary && cmdSummary.trim() !== "" ? cmdSummary : this.cmd.description().includes("\n") ? this.cmd.description().split("\n")[0] : void 0;
34
- }
35
- get description() {
36
- return this.cmd.description();
37
- }
38
- get hidden() {
39
- return Reflect.get(this.cmd, "_hidden");
40
- }
41
- get usage() {
42
- return this.cmd.usage();
43
- }
44
- get group() {
45
- return this.cmd.helpGroup();
46
- }
47
- get commands() {
48
- return this.cmd.commands.map((c) => new _CommanderHelpAdapter(c));
49
- }
50
- get options() {
51
- return this.cmd.options.map((opt) => ({
52
- ...opt,
53
- short: opt.short ?? opt.attributeName()[0],
54
- long: opt.long ?? opt.attributeName()
55
- }));
56
- }
57
- get arguments() {
58
- return this.cmd.registeredArguments.map((arg) => ({
59
- ...arg,
60
- name: arg.name()
61
- }));
62
- }
63
- get parent() {
64
- return this.cmd.parent ? new _CommanderHelpAdapter(this.cmd.parent) : null;
65
- }
66
- get helpConfiguration() {
67
- return { ...this.cmd.configureHelp() };
68
- }
69
- };
70
- __decorateClass([
71
- lazyProp
72
- ], _CommanderHelpAdapter.prototype, "summary", 1);
73
- __decorateClass([
74
- lazyProp
75
- ], _CommanderHelpAdapter.prototype, "commands", 1);
76
- __decorateClass([
77
- lazyProp
78
- ], _CommanderHelpAdapter.prototype, "options", 1);
79
- __decorateClass([
80
- lazyProp
81
- ], _CommanderHelpAdapter.prototype, "arguments", 1);
82
- __decorateClass([
83
- lazyProp
84
- ], _CommanderHelpAdapter.prototype, "parent", 1);
85
- __decorateClass([
86
- lazyProp
87
- ], _CommanderHelpAdapter.prototype, "helpConfiguration", 1);
88
- let CommanderHelpAdapter = _CommanderHelpAdapter;
89
- export {
90
- CommanderHelpAdapter
91
- };
92
- //# sourceMappingURL=CommanderHelpAdapter.js.map
@@ -1,5 +0,0 @@
1
- /**
2
- * Decorator to make a getter accessor property lazy loaded by setting the property value on the object
3
- */
4
- export default function lazyProp(target: unknown, key: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor;
5
- //# sourceMappingURL=lazyProp.d.ts.map
@@ -1,24 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- function lazyProp(target, key, descriptor) {
4
- const orig = descriptor.get;
5
- if (typeof orig !== "function") {
6
- throw new Error('"get" not a function');
7
- }
8
- descriptor.get = function() {
9
- const value = orig.call(this);
10
- Object.defineProperty(this, key, {
11
- enumerable: false,
12
- writable: false,
13
- configurable: true,
14
- value
15
- });
16
- return value;
17
- };
18
- return descriptor;
19
- }
20
- __name(lazyProp, "lazyProp");
21
- export {
22
- lazyProp as default
23
- };
24
- //# sourceMappingURL=lazyProp.js.map
@@ -1,6 +0,0 @@
1
- import { ICommandHelp, IHelp } from './Help';
2
- /**
3
- * Renders help for a command using the specified help instance.
4
- */
5
- export declare function renderHelp(cmd: ICommandHelp, help?: IHelp): string;
6
- //# sourceMappingURL=renderHelp.d.ts.map
package/lib/renderHelp.js DELETED
@@ -1,12 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { Help } from "./Help.js";
4
- function renderHelp(cmd, help = new Help()) {
5
- const helper = Object.assign(help, cmd.helpConfiguration);
6
- return helper.formatHelp(cmd, helper);
7
- }
8
- __name(renderHelp, "renderHelp");
9
- export {
10
- renderHelp
11
- };
12
- //# sourceMappingURL=renderHelp.js.map