@bemoje/cli 3.0.0 → 3.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.
- package/README.md +475 -0
- package/lib/index.cjs +61 -0
- package/lib/index.d.cts +6 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +8 -0
- package/lib/lib/Command.cjs +450 -0
- package/lib/lib/Command.d.cts +1 -0
- package/lib/lib/Command.d.ts +1 -0
- package/lib/lib/Command.js +443 -0
- package/lib/lib/Help.cjs +552 -0
- package/lib/lib/Help.d.cts +1 -0
- package/lib/lib/Help.d.ts +1 -0
- package/lib/lib/Help.js +545 -0
- package/lib/lib/helpers/findCommand.cjs +14 -0
- package/lib/lib/helpers/findCommand.d.cts +8 -0
- package/lib/lib/helpers/findCommand.d.ts +8 -0
- package/lib/lib/helpers/findCommand.js +11 -0
- package/lib/lib/helpers/findOption.cjs +16 -0
- package/lib/lib/helpers/findOption.d.cts +8 -0
- package/lib/lib/helpers/findOption.d.ts +8 -0
- package/lib/lib/helpers/findOption.js +14 -0
- package/lib/lib/helpers/getCommandAncestors.cjs +12 -0
- package/lib/lib/helpers/getCommandAncestors.d.cts +8 -0
- package/lib/lib/helpers/getCommandAncestors.d.ts +8 -0
- package/lib/lib/helpers/getCommandAncestors.js +9 -0
- package/lib/lib/helpers/getCommandAndAncestors.cjs +15 -0
- package/lib/lib/helpers/getCommandAndAncestors.d.cts +8 -0
- package/lib/lib/helpers/getCommandAndAncestors.d.ts +8 -0
- package/lib/lib/helpers/getCommandAndAncestors.js +13 -0
- package/lib/lib/helpers/parseOptionFlags.cjs +28 -0
- package/lib/lib/helpers/parseOptionFlags.d.cts +13 -0
- package/lib/lib/helpers/parseOptionFlags.d.ts +13 -0
- package/lib/lib/helpers/parseOptionFlags.js +26 -0
- package/lib/lib/types.cjs +2 -0
- package/lib/lib/types.d.cts +1 -0
- package/lib/lib/types.d.ts +1 -0
- package/lib/lib/types.js +1 -0
- package/package.json +144 -24
- package/index.d.ts +0 -711
- package/index.mjs +0 -1537
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
function getCommandAndAncestors(cmd) {
|
|
6
|
+
const result = [];
|
|
7
|
+
let command = cmd;
|
|
8
|
+
for (; command; command = command.parent) {
|
|
9
|
+
result.push(command);
|
|
10
|
+
}
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
__name(getCommandAndAncestors, "getCommandAndAncestors");
|
|
14
|
+
|
|
15
|
+
exports.getCommandAndAncestors = getCommandAndAncestors;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { I as ICommand } from '../../Command--Ojy3KHE.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns command and all ancestor commands in hierarchy
|
|
5
|
+
*/
|
|
6
|
+
declare function getCommandAndAncestors<C extends ICommand>(cmd: C): [typeof cmd, ...ICommand[]];
|
|
7
|
+
|
|
8
|
+
export { getCommandAndAncestors };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { I as ICommand } from '../../Command--Ojy3KHE.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns command and all ancestor commands in hierarchy
|
|
5
|
+
*/
|
|
6
|
+
declare function getCommandAndAncestors<C extends ICommand>(cmd: C): [typeof cmd, ...ICommand[]];
|
|
7
|
+
|
|
8
|
+
export { getCommandAndAncestors };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { __name } from '../../chunk-SHUYVCID.js';
|
|
2
|
+
|
|
3
|
+
function getCommandAndAncestors(cmd) {
|
|
4
|
+
const result = [];
|
|
5
|
+
let command = cmd;
|
|
6
|
+
for (; command; command = command.parent) {
|
|
7
|
+
result.push(command);
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
__name(getCommandAndAncestors, "getCommandAndAncestors");
|
|
12
|
+
|
|
13
|
+
export { getCommandAndAncestors };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
function parseOptionFlags(flags) {
|
|
6
|
+
const match = flags.match(/^-(.+?), --([A-Za-z][\w-]*)(?:\s*(<(.+?)>|\[(.+?)]))?$/);
|
|
7
|
+
if (!match) {
|
|
8
|
+
throw new Error(`Invalid option format: ${flags}`);
|
|
9
|
+
}
|
|
10
|
+
const short = match[1];
|
|
11
|
+
if (short.length !== 1) {
|
|
12
|
+
throw new Error(`Expected short name to be a single character. Got: -${short}`);
|
|
13
|
+
}
|
|
14
|
+
const long = match[2];
|
|
15
|
+
const argName = (match[4] || match[5])?.replace(/\.{3}$/, "") || void 0;
|
|
16
|
+
const name = long.split("-").reduce((str, word) => {
|
|
17
|
+
return str + word[0].toUpperCase() + word.slice(1);
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
short,
|
|
21
|
+
long,
|
|
22
|
+
name,
|
|
23
|
+
argName
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
__name(parseOptionFlags, "parseOptionFlags");
|
|
27
|
+
|
|
28
|
+
exports.parseOptionFlags = parseOptionFlags;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { m as OptionUsage, D as CamelCase } from '../../Command--Ojy3KHE.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parses option flags string into its components
|
|
5
|
+
*/
|
|
6
|
+
declare function parseOptionFlags<Long extends string>(flags: OptionUsage<Long>): {
|
|
7
|
+
short: string;
|
|
8
|
+
long: Long;
|
|
9
|
+
name: CamelCase<Long>;
|
|
10
|
+
argName: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { parseOptionFlags };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { m as OptionUsage, D as CamelCase } from '../../Command--Ojy3KHE.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parses option flags string into its components
|
|
5
|
+
*/
|
|
6
|
+
declare function parseOptionFlags<Long extends string>(flags: OptionUsage<Long>): {
|
|
7
|
+
short: string;
|
|
8
|
+
long: Long;
|
|
9
|
+
name: CamelCase<Long>;
|
|
10
|
+
argName: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { parseOptionFlags };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { __name } from '../../chunk-SHUYVCID.js';
|
|
2
|
+
|
|
3
|
+
function parseOptionFlags(flags) {
|
|
4
|
+
const match = flags.match(/^-(.+?), --([A-Za-z][\w-]*)(?:\s*(<(.+?)>|\[(.+?)]))?$/);
|
|
5
|
+
if (!match) {
|
|
6
|
+
throw new Error(`Invalid option format: ${flags}`);
|
|
7
|
+
}
|
|
8
|
+
const short = match[1];
|
|
9
|
+
if (short.length !== 1) {
|
|
10
|
+
throw new Error(`Expected short name to be a single character. Got: -${short}`);
|
|
11
|
+
}
|
|
12
|
+
const long = match[2];
|
|
13
|
+
const argName = (match[4] || match[5])?.replace(/\.{3}$/, "") || void 0;
|
|
14
|
+
const name = long.split("-").reduce((str, word) => {
|
|
15
|
+
return str + word[0].toUpperCase() + word.slice(1);
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
short,
|
|
19
|
+
long,
|
|
20
|
+
name,
|
|
21
|
+
argName
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
__name(parseOptionFlags, "parseOptionFlags");
|
|
25
|
+
|
|
26
|
+
export { parseOptionFlags };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { A as ActionHandler, a as AllowedArgumentUsage, b as Argument, c as ArgumentOptions, d as ArgumentUsage, e as Arguments, B as BooleanOptionOptions, f as HookActionHandler, g as HookDefinition, h as HookPredicate, I as ICommand, i as IHelp, j as InferAddOptionResult, k as InferAddedArgumentType, L as Logger, O as Option, l as OptionOptions, m as OptionUsage, n as OptionalArgumentOptions, o as OptionalArgumentOptionsWithDefaultValue, p as OptionalArgumentUsage, q as OptionalOptionOptions, r as OptionalVariadicArgumentOptions, s as OptionalVariadicArgumentUsage, t as OptionalVariadicOptionOptions, u as Options, P as ParseArgvResult, R as RequiredArgumentOptions, v as RequiredArgumentUsage, w as RequiredOptionOptions, x as RequiredVariadicArgumentOptions, y as RequiredVariadicArgumentUsage, z as RequiredVariadicOptionOptions, S as SubCommands } from '../Command--Ojy3KHE.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { A as ActionHandler, a as AllowedArgumentUsage, b as Argument, c as ArgumentOptions, d as ArgumentUsage, e as Arguments, B as BooleanOptionOptions, f as HookActionHandler, g as HookDefinition, h as HookPredicate, I as ICommand, i as IHelp, j as InferAddOptionResult, k as InferAddedArgumentType, L as Logger, O as Option, l as OptionOptions, m as OptionUsage, n as OptionalArgumentOptions, o as OptionalArgumentOptionsWithDefaultValue, p as OptionalArgumentUsage, q as OptionalOptionOptions, r as OptionalVariadicArgumentOptions, s as OptionalVariadicArgumentUsage, t as OptionalVariadicOptionOptions, u as Options, P as ParseArgvResult, R as RequiredArgumentOptions, v as RequiredArgumentUsage, w as RequiredOptionOptions, x as RequiredVariadicArgumentOptions, y as RequiredVariadicArgumentUsage, z as RequiredVariadicOptionOptions, S as SubCommands } from '../Command--Ojy3KHE.js';
|
package/lib/lib/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/package.json
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/cli",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "A type-safe CLI
|
|
5
|
-
"type": "module",
|
|
6
|
-
"sideEffects": false,
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "A type-safe CLI framework for building command-line interfaces with typed arguments, options, subcommands, and auto-generated help - without execution coupling.",
|
|
7
5
|
"keywords": [
|
|
8
6
|
"cli",
|
|
9
7
|
"command-line",
|
|
@@ -20,35 +18,157 @@
|
|
|
20
18
|
"args",
|
|
21
19
|
"argv"
|
|
22
20
|
],
|
|
23
|
-
"exports": {
|
|
24
|
-
".": {
|
|
25
|
-
"types": "./index.d.ts",
|
|
26
|
-
"import": "./index.mjs",
|
|
27
|
-
"default": "./index.mjs"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
21
|
"dependencies": {
|
|
31
22
|
"ansi-colors": "^4.1.3",
|
|
32
|
-
"
|
|
33
|
-
"es-toolkit": "^1.44.0",
|
|
34
|
-
"humanize-duration": "^3.33.2",
|
|
35
|
-
"memoizee": "^0.4.17",
|
|
36
|
-
"type-fest": "^5.4.4",
|
|
37
|
-
"@types/humanize-duration": "^3.27.4",
|
|
38
|
-
"@types/memoizee": "^0.4.12"
|
|
23
|
+
"es-toolkit": "^1.45.1"
|
|
39
24
|
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
40
27
|
"publishConfig": {
|
|
41
28
|
"access": "public"
|
|
42
29
|
},
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
30
|
+
"main": "./lib/index.cjs",
|
|
31
|
+
"module": "./lib/index.js",
|
|
32
|
+
"types": "./lib/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./lib/index.d.ts",
|
|
37
|
+
"default": "./lib/index.js"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./lib/index.d.cts",
|
|
41
|
+
"default": "./lib/index.cjs"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"./lib/Command": {
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./lib/lib/Command.d.ts",
|
|
47
|
+
"default": "./lib/lib/Command.js"
|
|
48
|
+
},
|
|
49
|
+
"require": {
|
|
50
|
+
"types": "./lib/lib/Command.d.cts",
|
|
51
|
+
"default": "./lib/lib/Command.cjs"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"./lib/Help": {
|
|
55
|
+
"import": {
|
|
56
|
+
"types": "./lib/lib/Help.d.ts",
|
|
57
|
+
"default": "./lib/lib/Help.js"
|
|
58
|
+
},
|
|
59
|
+
"require": {
|
|
60
|
+
"types": "./lib/lib/Help.d.cts",
|
|
61
|
+
"default": "./lib/lib/Help.cjs"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"./lib/helpers/findCommand": {
|
|
65
|
+
"import": {
|
|
66
|
+
"types": "./lib/lib/helpers/findCommand.d.ts",
|
|
67
|
+
"default": "./lib/lib/helpers/findCommand.js"
|
|
68
|
+
},
|
|
69
|
+
"require": {
|
|
70
|
+
"types": "./lib/lib/helpers/findCommand.d.cts",
|
|
71
|
+
"default": "./lib/lib/helpers/findCommand.cjs"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"./lib/helpers/findOption": {
|
|
75
|
+
"import": {
|
|
76
|
+
"types": "./lib/lib/helpers/findOption.d.ts",
|
|
77
|
+
"default": "./lib/lib/helpers/findOption.js"
|
|
78
|
+
},
|
|
79
|
+
"require": {
|
|
80
|
+
"types": "./lib/lib/helpers/findOption.d.cts",
|
|
81
|
+
"default": "./lib/lib/helpers/findOption.cjs"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"./lib/helpers/getCommandAncestors": {
|
|
85
|
+
"import": {
|
|
86
|
+
"types": "./lib/lib/helpers/getCommandAncestors.d.ts",
|
|
87
|
+
"default": "./lib/lib/helpers/getCommandAncestors.js"
|
|
88
|
+
},
|
|
89
|
+
"require": {
|
|
90
|
+
"types": "./lib/lib/helpers/getCommandAncestors.d.cts",
|
|
91
|
+
"default": "./lib/lib/helpers/getCommandAncestors.cjs"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"./lib/helpers/getCommandAndAncestors": {
|
|
95
|
+
"import": {
|
|
96
|
+
"types": "./lib/lib/helpers/getCommandAndAncestors.d.ts",
|
|
97
|
+
"default": "./lib/lib/helpers/getCommandAndAncestors.js"
|
|
98
|
+
},
|
|
99
|
+
"require": {
|
|
100
|
+
"types": "./lib/lib/helpers/getCommandAndAncestors.d.cts",
|
|
101
|
+
"default": "./lib/lib/helpers/getCommandAndAncestors.cjs"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"./lib/helpers/parseOptionFlags": {
|
|
105
|
+
"import": {
|
|
106
|
+
"types": "./lib/lib/helpers/parseOptionFlags.d.ts",
|
|
107
|
+
"default": "./lib/lib/helpers/parseOptionFlags.js"
|
|
108
|
+
},
|
|
109
|
+
"require": {
|
|
110
|
+
"types": "./lib/lib/helpers/parseOptionFlags.d.cts",
|
|
111
|
+
"default": "./lib/lib/helpers/parseOptionFlags.cjs"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"./lib/types": {
|
|
115
|
+
"import": {
|
|
116
|
+
"types": "./lib/lib/types.d.ts",
|
|
117
|
+
"default": "./lib/lib/types.js"
|
|
118
|
+
},
|
|
119
|
+
"require": {
|
|
120
|
+
"types": "./lib/lib/types.d.cts",
|
|
121
|
+
"default": "./lib/lib/types.cjs"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
48
124
|
},
|
|
125
|
+
"files": [
|
|
126
|
+
"./lib/index.js",
|
|
127
|
+
"./lib/index.d.ts",
|
|
128
|
+
"./lib/index.cjs",
|
|
129
|
+
"./lib/index.d.cts",
|
|
130
|
+
"./lib/lib/Command.js",
|
|
131
|
+
"./lib/lib/Command.d.ts",
|
|
132
|
+
"./lib/lib/Command.cjs",
|
|
133
|
+
"./lib/lib/Command.d.cts",
|
|
134
|
+
"./lib/lib/Help.js",
|
|
135
|
+
"./lib/lib/Help.d.ts",
|
|
136
|
+
"./lib/lib/Help.cjs",
|
|
137
|
+
"./lib/lib/Help.d.cts",
|
|
138
|
+
"./lib/lib/helpers/findCommand.js",
|
|
139
|
+
"./lib/lib/helpers/findCommand.d.ts",
|
|
140
|
+
"./lib/lib/helpers/findCommand.cjs",
|
|
141
|
+
"./lib/lib/helpers/findCommand.d.cts",
|
|
142
|
+
"./lib/lib/helpers/findOption.js",
|
|
143
|
+
"./lib/lib/helpers/findOption.d.ts",
|
|
144
|
+
"./lib/lib/helpers/findOption.cjs",
|
|
145
|
+
"./lib/lib/helpers/findOption.d.cts",
|
|
146
|
+
"./lib/lib/helpers/getCommandAncestors.js",
|
|
147
|
+
"./lib/lib/helpers/getCommandAncestors.d.ts",
|
|
148
|
+
"./lib/lib/helpers/getCommandAncestors.cjs",
|
|
149
|
+
"./lib/lib/helpers/getCommandAncestors.d.cts",
|
|
150
|
+
"./lib/lib/helpers/getCommandAndAncestors.js",
|
|
151
|
+
"./lib/lib/helpers/getCommandAndAncestors.d.ts",
|
|
152
|
+
"./lib/lib/helpers/getCommandAndAncestors.cjs",
|
|
153
|
+
"./lib/lib/helpers/getCommandAndAncestors.d.cts",
|
|
154
|
+
"./lib/lib/helpers/parseOptionFlags.js",
|
|
155
|
+
"./lib/lib/helpers/parseOptionFlags.d.ts",
|
|
156
|
+
"./lib/lib/helpers/parseOptionFlags.cjs",
|
|
157
|
+
"./lib/lib/helpers/parseOptionFlags.d.cts",
|
|
158
|
+
"./lib/lib/types.js",
|
|
159
|
+
"./lib/lib/types.d.ts",
|
|
160
|
+
"./lib/lib/types.cjs",
|
|
161
|
+
"./lib/lib/types.d.cts"
|
|
162
|
+
],
|
|
49
163
|
"repository": {
|
|
50
164
|
"type": "git",
|
|
51
165
|
"url": "git+https://github.com/bemoje/mono.git",
|
|
52
166
|
"directory": "libs/cli"
|
|
53
|
-
}
|
|
167
|
+
},
|
|
168
|
+
"author": {
|
|
169
|
+
"name": "Benjamin Møller Jensen",
|
|
170
|
+
"email": "bemoje@bemoje.net",
|
|
171
|
+
"url": "https://github.com/bemoje/"
|
|
172
|
+
},
|
|
173
|
+
"license": "MIT"
|
|
54
174
|
}
|