@clerc/core 0.41.0 → 0.42.1
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/LICENSE +21 -21
- package/README.md +1 -1
- package/dist/index.d.ts +22 -22
- package/dist/index.js +11 -10
- package/package.json +6 -6
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Ray <https://github.com/so1ve>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Ray <https://github.com/so1ve>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@clerc/core)
|
|
4
4
|
|
|
5
|
-
See [Clerc](https://github.com/
|
|
5
|
+
See [Clerc](https://github.com/clercjs/clerc) for documentation.
|
|
6
6
|
|
|
7
7
|
## 📝 License
|
|
8
8
|
|
package/dist/index.d.ts
CHANGED
|
@@ -282,7 +282,7 @@ declare class Clerc<C extends Commands = {}, GF extends GlobalFlagOptions = {}>
|
|
|
282
282
|
*
|
|
283
283
|
* ```ts
|
|
284
284
|
* Clerc.create().errorHandler((err) => {
|
|
285
|
-
*
|
|
285
|
+
* console.log(err);
|
|
286
286
|
* });
|
|
287
287
|
* ```
|
|
288
288
|
*
|
|
@@ -297,13 +297,13 @@ declare class Clerc<C extends Commands = {}, GF extends GlobalFlagOptions = {}>
|
|
|
297
297
|
*
|
|
298
298
|
* ```ts
|
|
299
299
|
* Clerc.create().command("test", "test command", {
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
300
|
+
* alias: "t",
|
|
301
|
+
* flags: {
|
|
302
|
+
* foo: {
|
|
303
|
+
* alias: "f",
|
|
304
|
+
* description: "foo flag",
|
|
305
|
+
* },
|
|
306
|
+
* },
|
|
307
307
|
* });
|
|
308
308
|
* ```
|
|
309
309
|
*
|
|
@@ -311,12 +311,12 @@ declare class Clerc<C extends Commands = {}, GF extends GlobalFlagOptions = {}>
|
|
|
311
311
|
*
|
|
312
312
|
* ```ts
|
|
313
313
|
* Clerc.create().command("", "root", {
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
314
|
+
* flags: {
|
|
315
|
+
* foo: {
|
|
316
|
+
* alias: "f",
|
|
317
|
+
* description: "foo flag",
|
|
318
|
+
* },
|
|
319
|
+
* },
|
|
320
320
|
* });
|
|
321
321
|
* ```
|
|
322
322
|
*
|
|
@@ -334,8 +334,8 @@ declare class Clerc<C extends Commands = {}, GF extends GlobalFlagOptions = {}>
|
|
|
334
334
|
*
|
|
335
335
|
* ```ts
|
|
336
336
|
* Clerc.create().flag("help", "help", {
|
|
337
|
-
*
|
|
338
|
-
*
|
|
337
|
+
* alias: "h",
|
|
338
|
+
* type: Boolean,
|
|
339
339
|
* });
|
|
340
340
|
* ```
|
|
341
341
|
*
|
|
@@ -352,10 +352,10 @@ declare class Clerc<C extends Commands = {}, GF extends GlobalFlagOptions = {}>
|
|
|
352
352
|
*
|
|
353
353
|
* ```ts
|
|
354
354
|
* Clerc.create()
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
355
|
+
* .command("test", "test command")
|
|
356
|
+
* .on("test", (ctx) => {
|
|
357
|
+
* console.log(ctx);
|
|
358
|
+
* });
|
|
359
359
|
* ```
|
|
360
360
|
*
|
|
361
361
|
* @param name
|
|
@@ -383,8 +383,8 @@ declare class Clerc<C extends Commands = {}, GF extends GlobalFlagOptions = {}>
|
|
|
383
383
|
*
|
|
384
384
|
* ```ts
|
|
385
385
|
* Clerc.create().inspector((ctx, next) => {
|
|
386
|
-
*
|
|
387
|
-
*
|
|
386
|
+
* console.log(ctx);
|
|
387
|
+
* next();
|
|
388
388
|
* });
|
|
389
389
|
* ```
|
|
390
390
|
*
|
package/dist/index.js
CHANGED
|
@@ -472,7 +472,7 @@ const _Clerc = class {
|
|
|
472
472
|
*
|
|
473
473
|
* ```ts
|
|
474
474
|
* Clerc.create().errorHandler((err) => {
|
|
475
|
-
*
|
|
475
|
+
* console.log(err);
|
|
476
476
|
* });
|
|
477
477
|
* ```
|
|
478
478
|
*
|
|
@@ -494,8 +494,8 @@ const _Clerc = class {
|
|
|
494
494
|
*
|
|
495
495
|
* ```ts
|
|
496
496
|
* Clerc.create().flag("help", "help", {
|
|
497
|
-
*
|
|
498
|
-
*
|
|
497
|
+
* alias: "h",
|
|
498
|
+
* type: Boolean,
|
|
499
499
|
* });
|
|
500
500
|
* ```
|
|
501
501
|
*
|
|
@@ -518,10 +518,10 @@ const _Clerc = class {
|
|
|
518
518
|
*
|
|
519
519
|
* ```ts
|
|
520
520
|
* Clerc.create()
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
521
|
+
* .command("test", "test command")
|
|
522
|
+
* .on("test", (ctx) => {
|
|
523
|
+
* console.log(ctx);
|
|
524
|
+
* });
|
|
525
525
|
* ```
|
|
526
526
|
*
|
|
527
527
|
* @param name
|
|
@@ -555,8 +555,8 @@ const _Clerc = class {
|
|
|
555
555
|
*
|
|
556
556
|
* ```ts
|
|
557
557
|
* Clerc.create().inspector((ctx, next) => {
|
|
558
|
-
*
|
|
559
|
-
*
|
|
558
|
+
* console.log(ctx);
|
|
559
|
+
* next();
|
|
560
560
|
* });
|
|
561
561
|
* ```
|
|
562
562
|
*
|
|
@@ -698,8 +698,9 @@ getContext_fn = function(getCommand) {
|
|
|
698
698
|
...command == null ? void 0 : command.flags
|
|
699
699
|
};
|
|
700
700
|
const parsed = typeFlag(flagsMerged, [...argv]);
|
|
701
|
+
const parametersOffset = (command == null ? void 0 : command.name) === Root || called === Root ? 0 : (called == null ? void 0 : called.length) ? called.length : command == null ? void 0 : command.name.split(" ").length;
|
|
701
702
|
const { _: args, flags, unknownFlags } = parsed;
|
|
702
|
-
let parameters = !isCommandResolved || command.name === Root ? args : args.slice(
|
|
703
|
+
let parameters = !isCommandResolved || command.name === Root ? args : args.slice(parametersOffset);
|
|
703
704
|
let commandParameters = (_a = command == null ? void 0 : command.parameters) != null ? _a : [];
|
|
704
705
|
const hasEof = commandParameters.indexOf("--");
|
|
705
706
|
const eofParameters = commandParameters.slice(hasEof + 1) || [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.1",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clerc core",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"cli",
|
|
13
13
|
"terminal"
|
|
14
14
|
],
|
|
15
|
-
"homepage": "https://github.com/
|
|
15
|
+
"homepage": "https://github.com/clercjs/clerc/tree/main/packages/core#readme",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/
|
|
18
|
+
"url": "git+https://github.com/clercjs/clerc.git",
|
|
19
19
|
"directory": "/"
|
|
20
20
|
},
|
|
21
21
|
"bugs": {
|
|
22
|
-
"url": "https://github.com/
|
|
22
|
+
"url": "https://github.com/clercjs/clerc/issues"
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"sideEffects": false,
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"defu": "^6.1.2",
|
|
51
51
|
"is-platform": "^1.0.0",
|
|
52
52
|
"lite-emit": "^2.2.0",
|
|
53
|
-
"type-fest": "^
|
|
53
|
+
"type-fest": "^4.0.0",
|
|
54
54
|
"type-flag": "^3.0.0",
|
|
55
|
-
"@clerc/utils": "0.
|
|
55
|
+
"@clerc/utils": "0.42.1"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "pkgroll",
|