args-tokens 0.19.0 → 0.20.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/lib/index.d.ts +5 -6
- package/lib/index.js +2 -1
- package/lib/{parser-Bx112mWZ.d.ts → parser-FiQIAw-2.d.ts} +2 -1
- package/lib/parser.d.ts +1 -1
- package/lib/{resolver-Df1uPA8Z.js → resolver-Q4k2fgTW.js} +1 -3
- package/lib/{resolver-COGeGqd3.d.ts → resolver-U72Jg6Ll.d.ts} +8 -12
- package/lib/resolver.d.ts +3 -3
- package/lib/resolver.js +2 -1
- package/lib/utils-N7UlhLbz.js +18 -0
- package/lib/utils.d.ts +15 -0
- package/lib/utils.js +3 -0
- package/package.json +17 -11
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { ArgToken, ParserOptions, parseArgs$1 as parseArgs } from "./parser-
|
|
2
|
-
import { ArgResolveError$1 as ArgResolveError, ArgResolveErrorType, ArgSchema, ArgValues, Args, ResolveArgs, resolveArgs$1 as resolveArgs } from "./resolver-
|
|
1
|
+
import { ArgToken, ParserOptions, parseArgs$1 as parseArgs } from "./parser-FiQIAw-2.js";
|
|
2
|
+
import { ArgResolveError$1 as ArgResolveError, ArgResolveErrorType, ArgSchema, ArgValues, Args, ResolveArgs, resolveArgs$1 as resolveArgs } from "./resolver-U72Jg6Ll.js";
|
|
3
3
|
|
|
4
4
|
//#region src/parse.d.ts
|
|
5
|
-
|
|
6
|
-
* Parse options for {@link parse} function.
|
|
7
|
-
*/
|
|
5
|
+
|
|
8
6
|
/**
|
|
9
7
|
* Parse options for {@link parse} function.
|
|
10
8
|
*/
|
|
@@ -54,5 +52,6 @@ type ParsedArgs<A extends Args> = {
|
|
|
54
52
|
* @param options - parse options, about details see {@link ParseOptions}
|
|
55
53
|
* @returns An object that contains the values of the arguments, positional arguments, {@link AggregateError | validation errors}, and {@link ArgToken | argument tokens}.
|
|
56
54
|
*/
|
|
57
|
-
declare function parse<A extends Args>(args: string[], options?: ParseOptions<A>): ParsedArgs<A>;
|
|
55
|
+
declare function parse<A extends Args>(args: string[], options?: ParseOptions<A>): ParsedArgs<A>;
|
|
56
|
+
//#endregion
|
|
58
57
|
export { ArgResolveError, ArgResolveErrorType, ArgSchema, ArgToken, ArgValues, Args, ParseOptions, ParsedArgs, ParserOptions, ResolveArgs, parse, parseArgs, resolveArgs };
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parseArgs } from "./parser-Dr4iAGaX.js";
|
|
2
|
-
import
|
|
2
|
+
import "./utils-N7UlhLbz.js";
|
|
3
|
+
import { ArgResolveError, resolveArgs } from "./resolver-Q4k2fgTW.js";
|
|
3
4
|
|
|
4
5
|
//#region src/parse.ts
|
|
5
6
|
const DEFAULT_OPTIONS = {
|
|
@@ -86,5 +86,6 @@ declare function isShortOption(arg: string): boolean;
|
|
|
86
86
|
* @param arg the argument to check
|
|
87
87
|
* @returns whether `arg` is a long option prefix.
|
|
88
88
|
*/
|
|
89
|
-
declare function hasLongOptionPrefix(arg: string): boolean;
|
|
89
|
+
declare function hasLongOptionPrefix(arg: string): boolean;
|
|
90
|
+
//#endregion
|
|
90
91
|
export { ArgToken, ParserOptions, hasLongOptionPrefix as hasLongOptionPrefix$1, isShortOption as isShortOption$1, parseArgs as parseArgs$1 };
|
package/lib/parser.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ArgToken, ParserOptions, hasLongOptionPrefix$1 as hasLongOptionPrefix, isShortOption$1 as isShortOption, parseArgs$1 as parseArgs } from "./parser-
|
|
1
|
+
import { ArgToken, ParserOptions, hasLongOptionPrefix$1 as hasLongOptionPrefix, isShortOption$1 as isShortOption, parseArgs$1 as parseArgs } from "./parser-FiQIAw-2.js";
|
|
2
2
|
export { ArgToken, ParserOptions, hasLongOptionPrefix, isShortOption, parseArgs };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { hasLongOptionPrefix, isShortOption } from "./parser-Dr4iAGaX.js";
|
|
2
|
+
import { kebabnize } from "./utils-N7UlhLbz.js";
|
|
2
3
|
|
|
3
4
|
//#region src/resolver.ts
|
|
4
5
|
const SKIP_POSITIONAL_DEFAULT = -1;
|
|
5
|
-
function kebabnize(str) {
|
|
6
|
-
return str.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase());
|
|
7
|
-
}
|
|
8
6
|
/**
|
|
9
7
|
* Resolve command line arguments.
|
|
10
8
|
* @param args - An arguments that contains {@link ArgSchema | arguments schema}.
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { ArgToken } from "./parser-
|
|
1
|
+
import { ArgToken } from "./parser-FiQIAw-2.js";
|
|
2
2
|
|
|
3
3
|
//#region src/resolver.d.ts
|
|
4
|
-
|
|
5
|
-
* An argument schema
|
|
6
|
-
* This schema is similar to the schema of the `node:utils`.
|
|
7
|
-
* difference is that:
|
|
8
|
-
* - `required` property and `description` property are added
|
|
9
|
-
* - `type` is not only 'string' and 'boolean', but also 'number', 'enum', 'positional', 'custom' too.
|
|
10
|
-
* - `default` property type, not support multiple types
|
|
11
|
-
*/
|
|
4
|
+
|
|
12
5
|
/**
|
|
13
6
|
* An argument schema
|
|
14
7
|
* This schema is similar to the schema of the `node:utils`.
|
|
@@ -87,12 +80,16 @@ type ResolveOptionValue<A extends ArgSchema, T> = A["multiple"] extends true ? T
|
|
|
87
80
|
/**
|
|
88
81
|
* @internal
|
|
89
82
|
*/
|
|
90
|
-
type ResolveArgValues<A extends Args, V extends Record<keyof A, unknown>> = { -readonly [Arg in keyof A]?: V[Arg] } & FilterArgs<A, V, "default"> & FilterArgs<A, V, "required"> extends infer P ? { [K in keyof P]: P[K] } : never;
|
|
83
|
+
type ResolveArgValues<A extends Args, V extends Record<keyof A, unknown>> = { -readonly [Arg in keyof A]?: V[Arg] } & FilterArgs<A, V, "default"> & FilterArgs<A, V, "required"> & FilterPositionalArgs<A, V> extends infer P ? { [K in keyof P]: P[K] } : never;
|
|
91
84
|
/**
|
|
92
85
|
* @internal
|
|
93
86
|
*/
|
|
94
87
|
type FilterArgs<A extends Args, V extends Record<keyof A, unknown>, K extends keyof ArgSchema> = { [Arg in keyof A as A[Arg][K] extends {} ? Arg : never]: V[Arg] };
|
|
95
88
|
/**
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
type FilterPositionalArgs<A extends Args, V extends Record<keyof A, unknown>> = { [Arg in keyof A as A[Arg]["type"] extends "positional" ? Arg : never]: V[Arg] };
|
|
92
|
+
/**
|
|
96
93
|
* An arguments for {@link resolveArgs | resolve arguments}.
|
|
97
94
|
*/
|
|
98
95
|
interface ResolveArgs {
|
|
@@ -144,6 +141,5 @@ declare class ArgResolveError extends Error {
|
|
|
144
141
|
type: ArgResolveErrorType;
|
|
145
142
|
constructor(message: string, name: string, type: ArgResolveErrorType, schema: ArgSchema);
|
|
146
143
|
}
|
|
147
|
-
|
|
148
144
|
//#endregion
|
|
149
|
-
export { ArgResolveError as ArgResolveError$1, ArgResolveErrorType, ArgSchema, ArgValues, Args, ExtractOptionValue, FilterArgs, ResolveArgValues, ResolveArgs, resolveArgs as resolveArgs$1 };
|
|
145
|
+
export { ArgResolveError as ArgResolveError$1, ArgResolveErrorType, ArgSchema, ArgValues, Args, ExtractOptionValue, FilterArgs, FilterPositionalArgs, ResolveArgValues, ResolveArgs, resolveArgs as resolveArgs$1 };
|
package/lib/resolver.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./parser-
|
|
2
|
-
import { ArgResolveError$1 as ArgResolveError, ArgResolveErrorType, ArgSchema, ArgValues, Args, ExtractOptionValue, FilterArgs, ResolveArgValues, ResolveArgs, resolveArgs$1 as resolveArgs } from "./resolver-
|
|
3
|
-
export { ArgResolveError, ArgResolveErrorType, ArgSchema, ArgValues, Args, ExtractOptionValue, FilterArgs, ResolveArgValues, ResolveArgs, resolveArgs };
|
|
1
|
+
import "./parser-FiQIAw-2.js";
|
|
2
|
+
import { ArgResolveError$1 as ArgResolveError, ArgResolveErrorType, ArgSchema, ArgValues, Args, ExtractOptionValue, FilterArgs, FilterPositionalArgs, ResolveArgValues, ResolveArgs, resolveArgs$1 as resolveArgs } from "./resolver-U72Jg6Ll.js";
|
|
3
|
+
export { ArgResolveError, ArgResolveErrorType, ArgSchema, ArgValues, Args, ExtractOptionValue, FilterArgs, FilterPositionalArgs, ResolveArgValues, ResolveArgs, resolveArgs };
|
package/lib/resolver.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Entry point of utils.
|
|
4
|
+
*
|
|
5
|
+
* Note that this entry point is used by gunshi to import utility functions.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
11
|
+
* @license MIT
|
|
12
|
+
*/
|
|
13
|
+
function kebabnize(str) {
|
|
14
|
+
return str.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { kebabnize };
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/utils.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Entry point of utils.
|
|
4
|
+
*
|
|
5
|
+
* Note that this entry point is used by gunshi to import utility functions.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
11
|
+
* @license MIT
|
|
12
|
+
*/
|
|
13
|
+
declare function kebabnize(str: string): string;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { kebabnize };
|
package/lib/utils.js
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "args-tokens",
|
|
3
3
|
"description": "parseArgs tokens compatibility and more high-performance parser",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.20.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -52,6 +52,12 @@
|
|
|
52
52
|
"require": "./lib/resolver.js",
|
|
53
53
|
"default": "./lib/resolver.js"
|
|
54
54
|
},
|
|
55
|
+
"./utils": {
|
|
56
|
+
"types": "./lib/utils.d.ts",
|
|
57
|
+
"import": "./lib/utils.js",
|
|
58
|
+
"require": "./lib/utils.js",
|
|
59
|
+
"default": "./lib/utils.js"
|
|
60
|
+
},
|
|
55
61
|
"./package.json": "./package.json",
|
|
56
62
|
"./*": "./*"
|
|
57
63
|
},
|
|
@@ -68,11 +74,11 @@
|
|
|
68
74
|
"@eslint/markdown": "^6.4.0",
|
|
69
75
|
"@kazupon/eslint-config": "^0.29.0",
|
|
70
76
|
"@kazupon/prettier-config": "^0.1.1",
|
|
71
|
-
"@types/node": "^22.15.
|
|
72
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
73
|
-
"@vitest/eslint-plugin": "^1.2.
|
|
77
|
+
"@types/node": "^22.15.27",
|
|
78
|
+
"@typescript/native-preview": "7.0.0-dev.20250529.1",
|
|
79
|
+
"@vitest/eslint-plugin": "^1.2.1",
|
|
74
80
|
"bumpp": "^10.1.1",
|
|
75
|
-
"deno": "^2.3.
|
|
81
|
+
"deno": "^2.3.4",
|
|
76
82
|
"eslint": "^9.27.0",
|
|
77
83
|
"eslint-config-prettier": "^10.1.5",
|
|
78
84
|
"eslint-plugin-jsonc": "^2.20.1",
|
|
@@ -83,16 +89,16 @@
|
|
|
83
89
|
"gh-changelogen": "^0.2.8",
|
|
84
90
|
"jsr": "^0.13.4",
|
|
85
91
|
"jsr-exports-lint": "^0.4.0",
|
|
86
|
-
"knip": "^5.
|
|
87
|
-
"lint-staged": "^
|
|
92
|
+
"knip": "^5.59.1",
|
|
93
|
+
"lint-staged": "^16.0.0",
|
|
88
94
|
"mitata": "^1.0.34",
|
|
89
|
-
"pkg-pr-new": "^0.0.
|
|
95
|
+
"pkg-pr-new": "^0.0.51",
|
|
90
96
|
"prettier": "^3.5.3",
|
|
91
|
-
"tsdown": "^0.12.
|
|
97
|
+
"tsdown": "^0.12.4",
|
|
92
98
|
"typescript": "^5.8.3",
|
|
93
|
-
"typescript-eslint": "^8.
|
|
99
|
+
"typescript-eslint": "^8.33.0",
|
|
94
100
|
"vitest": "^3.1.4",
|
|
95
|
-
"zod": "^3.25.
|
|
101
|
+
"zod": "^3.25.41"
|
|
96
102
|
},
|
|
97
103
|
"prettier": "@kazupon/prettier-config",
|
|
98
104
|
"lint-staged": {
|