breadc 0.8.6 → 0.8.8
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 +4 -3
- package/dist/index.cjs +7 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +7 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Breadc
|
|
1
|
+
# 🥪 Breadc
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/breadc) [](https://github.com/yjl9903/Breadc/actions/workflows/ci.yml) [](https://codecov.io/gh/yjl9903/Breadc)
|
|
4
4
|
|
|
@@ -8,9 +8,10 @@ Yet another Command Line Application Framework with fully strong **[TypeScript](
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
+ ⚡️ **Light-weight**: Only 75 kB (Unpacked)
|
|
11
|
+
+ ⚡️ **Light-weight**: Only 75 kB (Unpacked);
|
|
12
|
+
+ 🔍 **TypeScript Infer**: IDE will automatically infer the type of your command action function;
|
|
13
|
+
+ 💻 **Commands**: Support default command, command alias and sub-commands like `git remote add <name> <url>`;
|
|
12
14
|
+ 📖 **East to Learn**: Breadc is basically compatible with [cac](https://github.com/cacjs/cac) and there are only 5 APIs for building a CLI application: `breadc`, `command`, `option`, `action`, `run`.
|
|
13
|
-
+ 💻 **TypeScript Infer**: IDE will automatically infer the type of your command action function.
|
|
14
15
|
|
|
15
16
|
## Installation
|
|
16
17
|
|
package/dist/index.cjs
CHANGED
|
@@ -295,13 +295,13 @@ function makeOption(format, config = {}) {
|
|
|
295
295
|
const match = OptionRE.exec(format);
|
|
296
296
|
if (match) {
|
|
297
297
|
name = match[2];
|
|
298
|
-
if (name.startsWith("no-")) {
|
|
299
|
-
throw new BreadcError(`Can not parse option format (${format})`);
|
|
300
|
-
}
|
|
301
298
|
if (match[1]) {
|
|
302
299
|
short = match[1][1];
|
|
303
300
|
}
|
|
304
301
|
if (match[3]) {
|
|
302
|
+
if (name.startsWith("no-")) {
|
|
303
|
+
throw new BreadcError(`Can not parse option format (${format})`);
|
|
304
|
+
}
|
|
305
305
|
const initial = config.default ?? "";
|
|
306
306
|
return {
|
|
307
307
|
format,
|
|
@@ -315,6 +315,10 @@ function makeOption(format, config = {}) {
|
|
|
315
315
|
cast: config.cast
|
|
316
316
|
};
|
|
317
317
|
} else {
|
|
318
|
+
if (name.startsWith("no-")) {
|
|
319
|
+
name = name.slice(3);
|
|
320
|
+
config.default = true;
|
|
321
|
+
}
|
|
318
322
|
const initial = config.default === void 0 || config.default === null ? false : config.default;
|
|
319
323
|
return {
|
|
320
324
|
format,
|
package/dist/index.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ type ExtractOptionType<T extends string> = T extends `-${Letter}, --${infer R} <
|
|
|
68
68
|
* + const t2: ExtractOption<'-r, --root'> = 'root'
|
|
69
69
|
* + const t3: ExtractOption<'--page-index'> = 'pageIndex'
|
|
70
70
|
*/
|
|
71
|
-
type ExtractOptionRawName<T extends string> = T extends `-${Letter}, --${infer R} <${infer U}>` ? R : T extends `-${Letter}, --${infer R}` ? R : T extends `--${infer R} <${infer U}>` ? R : T extends `--${infer R}` ? R : never;
|
|
71
|
+
type ExtractOptionRawName<T extends string> = T extends `-${Letter}, --${infer R} <${infer U}>` ? R : T extends `-${Letter}, --no-${infer R}` ? R : T extends `-${Letter}, --${infer R}` ? R : T extends `--${infer R} <${infer U}>` ? R : T extends `--no-${infer R}` ? R : T extends `--${infer R}` ? R : never;
|
|
72
72
|
/**
|
|
73
73
|
* Extrat camel case option name
|
|
74
74
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -291,13 +291,13 @@ function makeOption(format, config = {}) {
|
|
|
291
291
|
const match = OptionRE.exec(format);
|
|
292
292
|
if (match) {
|
|
293
293
|
name = match[2];
|
|
294
|
-
if (name.startsWith("no-")) {
|
|
295
|
-
throw new BreadcError(`Can not parse option format (${format})`);
|
|
296
|
-
}
|
|
297
294
|
if (match[1]) {
|
|
298
295
|
short = match[1][1];
|
|
299
296
|
}
|
|
300
297
|
if (match[3]) {
|
|
298
|
+
if (name.startsWith("no-")) {
|
|
299
|
+
throw new BreadcError(`Can not parse option format (${format})`);
|
|
300
|
+
}
|
|
301
301
|
const initial = config.default ?? "";
|
|
302
302
|
return {
|
|
303
303
|
format,
|
|
@@ -311,6 +311,10 @@ function makeOption(format, config = {}) {
|
|
|
311
311
|
cast: config.cast
|
|
312
312
|
};
|
|
313
313
|
} else {
|
|
314
|
+
if (name.startsWith("no-")) {
|
|
315
|
+
name = name.slice(3);
|
|
316
|
+
config.default = true;
|
|
317
|
+
}
|
|
314
318
|
const initial = config.default === void 0 || config.default === null ? false : config.default;
|
|
315
319
|
return {
|
|
316
320
|
format,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "breadc",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.8",
|
|
4
4
|
"description": "Yet another Command Line Application Framework with fully strong TypeScript support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"breadc",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@breadc/color": "0.8.
|
|
37
|
+
"@breadc/color": "0.8.8"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/node": "^18.
|
|
41
|
-
"@vitest/coverage-c8": "^0.
|
|
40
|
+
"@types/node": "^18.14.1",
|
|
41
|
+
"@vitest/coverage-c8": "^0.29.1",
|
|
42
42
|
"cac": "^6.7.14",
|
|
43
|
-
"vitest": "0.
|
|
43
|
+
"vitest": "0.29.1"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "unbuild",
|