@thi.ng/args
Advanced tools
Comparing version 2.1.14 to 2.2.0
# Change Log | ||
- **Last updated**: 2022-08-01T14:53:59Z | ||
- **Last updated**: 2022-08-15T23:41:37Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -12,2 +12,9 @@ | ||
## [2.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@2.2.0) (2022-08-15) | ||
#### 🚀 Features | ||
- add ParseError, update parse() err handling ([c854a13](https://github.com/thi-ng/umbrella/commit/c854a13)) | ||
- update parse() to re-throw any caught error wrapped as ParseError | ||
### [2.1.6](https://github.com/thi-ng/umbrella/tree/@thi.ng/args@2.1.6) (2022-04-07) | ||
@@ -14,0 +21,0 @@ |
{ | ||
"name": "@thi.ng/args", | ||
"version": "2.1.14", | ||
"version": "2.2.0", | ||
"description": "Declarative, functional & typechecked CLI argument/options parser, value coercions etc.", | ||
@@ -99,3 +99,3 @@ "type": "module", | ||
}, | ||
"gitHead": "295e76c6f68ef34ba2117ff77612848e09f5c587\n" | ||
"gitHead": "78193cdd838d9d09114352b117b6c5e92631e3cd\n" | ||
} |
@@ -0,4 +1,15 @@ | ||
/// <reference types="node" /> | ||
import type { IObjectOf } from "@thi.ng/api"; | ||
import type { Args, ParseOpts, ParseResult } from "./api.js"; | ||
export declare const ParseError: { | ||
new (msg?: string | undefined): { | ||
name: string; | ||
message: string; | ||
stack?: string | undefined; | ||
}; | ||
captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void; | ||
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined; | ||
stackTraceLimit: number; | ||
}; | ||
export declare const parse: <T extends IObjectOf<any>>(specs: Args<T>, argv: string[], opts?: Partial<ParseOpts>) => ParseResult<T> | undefined; | ||
//# sourceMappingURL=parse.d.ts.map |
import { isArray } from "@thi.ng/checks/is-array"; | ||
import { defError } from "@thi.ng/errors/deferror"; | ||
import { illegalArgs } from "@thi.ng/errors/illegal-arguments"; | ||
import { camel } from "@thi.ng/strings/case"; | ||
import { usage } from "./usage.js"; | ||
export const ParseError = defError(() => "parse error"); | ||
export const parse = (specs, argv, opts) => { | ||
@@ -14,3 +16,3 @@ opts = { start: 2, showUsage: true, help: ["--help", "-h"], ...opts }; | ||
} | ||
throw e; | ||
throw new ParseError(e.message); | ||
} | ||
@@ -17,0 +19,0 @@ }; |
59111
949