@thi.ng/args 2.1.13 → 2.2.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/CHANGELOG.md +8 -1
- package/README.md +1 -1
- package/package.json +5 -5
- package/parse.d.ts +11 -0
- package/parse.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2022-08-
|
|
3
|
+
- **Last updated**: 2022-08-23T10:37:04Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [2.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@2.2.0) (2022-08-15)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add ParseError, update parse() err handling ([c854a13](https://github.com/thi-ng/umbrella/commit/c854a13))
|
|
17
|
+
- update parse() to re-throw any caught error wrapped as ParseError
|
|
18
|
+
|
|
12
19
|
### [2.1.6](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@2.1.6) (2022-04-07)
|
|
13
20
|
|
|
14
21
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/args",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Declarative, functional & typechecked CLI argument/options parser, value coercions etc.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.
|
|
37
|
+
"@thi.ng/api": "^8.4.1",
|
|
38
38
|
"@thi.ng/checks": "^3.2.4",
|
|
39
39
|
"@thi.ng/errors": "^2.1.10",
|
|
40
|
-
"@thi.ng/strings": "^3.3.
|
|
40
|
+
"@thi.ng/strings": "^3.3.11"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@microsoft/api-extractor": "^7.25.0",
|
|
44
|
-
"@thi.ng/testament": "^0.2.
|
|
44
|
+
"@thi.ng/testament": "^0.2.12",
|
|
45
45
|
"rimraf": "^3.0.2",
|
|
46
46
|
"tools": "^0.0.1",
|
|
47
47
|
"typedoc": "^0.22.17",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"thi.ng": {
|
|
97
97
|
"year": 2018
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "be8423e2019e95c14a096260a93b9762dde0c768\n"
|
|
100
100
|
}
|
package/parse.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { IObjectOf } from "@thi.ng/api";
|
|
2
3
|
import type { Args, ParseOpts, ParseResult } from "./api.js";
|
|
4
|
+
export declare const ParseError: {
|
|
5
|
+
new (msg?: string | undefined): {
|
|
6
|
+
name: string;
|
|
7
|
+
message: string;
|
|
8
|
+
stack?: string | undefined;
|
|
9
|
+
};
|
|
10
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
|
|
11
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
12
|
+
stackTraceLimit: number;
|
|
13
|
+
};
|
|
3
14
|
export declare const parse: <T extends IObjectOf<any>>(specs: Args<T>, argv: string[], opts?: Partial<ParseOpts>) => ParseResult<T> | undefined;
|
|
4
15
|
//# sourceMappingURL=parse.d.ts.map
|
package/parse.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { isArray } from "@thi.ng/checks/is-array";
|
|
2
|
+
import { defError } from "@thi.ng/errors/deferror";
|
|
2
3
|
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
|
|
3
4
|
import { camel } from "@thi.ng/strings/case";
|
|
4
5
|
import { usage } from "./usage.js";
|
|
6
|
+
export const ParseError = defError(() => "parse error");
|
|
5
7
|
export const parse = (specs, argv, opts) => {
|
|
6
8
|
opts = { start: 2, showUsage: true, help: ["--help", "-h"], ...opts };
|
|
7
9
|
try {
|
|
@@ -11,7 +13,7 @@ export const parse = (specs, argv, opts) => {
|
|
|
11
13
|
if (opts.showUsage) {
|
|
12
14
|
console.log(e.message + "\n\n" + usage(specs, opts.usageOpts));
|
|
13
15
|
}
|
|
14
|
-
throw e;
|
|
16
|
+
throw new ParseError(e.message);
|
|
15
17
|
}
|
|
16
18
|
};
|
|
17
19
|
const parseOpts = (specs, argv, opts) => {
|