args-tokens 0.22.0 → 0.22.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 +1 -1
- package/lib/index.js +1 -1
- package/lib/{resolver-Bcd8oyPt.js → resolver-BsDoIgzu.js} +16 -8
- package/lib/resolver.js +1 -1
- package/package.json +15 -15
package/lib/index.d.ts
CHANGED
|
@@ -59,4 +59,4 @@ type ParsedArgs<A extends Args> = {
|
|
|
59
59
|
*/
|
|
60
60
|
declare function parse<A extends Args>(args: string[], options?: ParseOptions<A>): ParsedArgs<A>;
|
|
61
61
|
//#endregion
|
|
62
|
-
export { ArgExplicitlyProvided, ArgResolveError, ArgResolveErrorType, ArgSchema, ArgToken, ArgValues, Args, ParseOptions, ParsedArgs, ParserOptions, ResolveArgs, parse, parseArgs, resolveArgs };
|
|
62
|
+
export { type ArgExplicitlyProvided, ArgResolveError, type ArgResolveErrorType, type ArgSchema, type ArgToken, type ArgValues, type Args, type ParseOptions, type ParsedArgs, type ParserOptions, type ResolveArgs, parse, parseArgs, resolveArgs };
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseArgs } from "./parser-Dr4iAGaX.js";
|
|
2
2
|
import "./utils-N7UlhLbz.js";
|
|
3
|
-
import { ArgResolveError, resolveArgs } from "./resolver-
|
|
3
|
+
import { ArgResolveError, resolveArgs } from "./resolver-BsDoIgzu.js";
|
|
4
4
|
|
|
5
5
|
//#region src/parse.ts
|
|
6
6
|
const DEFAULT_OPTIONS = {
|
|
@@ -142,6 +142,22 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
142
142
|
for (const [rawArg, schema] of Object.entries(args)) {
|
|
143
143
|
const arg = toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
|
|
144
144
|
explicit[rawArg] = false;
|
|
145
|
+
if (schema.type === "positional") {
|
|
146
|
+
if (skipPositionalIndex > SKIP_POSITIONAL_DEFAULT) while (positionalsCount <= getPositionalSkipIndex()) positionalsCount++;
|
|
147
|
+
if (schema.multiple) {
|
|
148
|
+
const remainingPositionals = positionalTokens.slice(positionalsCount);
|
|
149
|
+
if (remainingPositionals.length > 0) {
|
|
150
|
+
values[rawArg] = remainingPositionals.map((p) => p.value);
|
|
151
|
+
positionalsCount += remainingPositionals.length;
|
|
152
|
+
} else if (schema.required) errors.push(createRequireError(arg, schema));
|
|
153
|
+
} else {
|
|
154
|
+
const positional = positionalTokens[positionalsCount];
|
|
155
|
+
if (positional != null) values[rawArg] = positional.value;
|
|
156
|
+
else errors.push(createRequireError(arg, schema));
|
|
157
|
+
positionalsCount++;
|
|
158
|
+
}
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
145
161
|
if (schema.required) {
|
|
146
162
|
const found = optionTokens.find((token) => {
|
|
147
163
|
return schema.short && token.name === schema.short || token.rawName && hasLongOptionPrefix(token.rawName) && token.name === arg;
|
|
@@ -151,14 +167,6 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
151
167
|
continue;
|
|
152
168
|
}
|
|
153
169
|
}
|
|
154
|
-
if (schema.type === "positional") {
|
|
155
|
-
if (skipPositionalIndex > SKIP_POSITIONAL_DEFAULT) while (positionalsCount <= getPositionalSkipIndex()) positionalsCount++;
|
|
156
|
-
const positional = positionalTokens[positionalsCount];
|
|
157
|
-
if (positional != null) values[rawArg] = positional.value;
|
|
158
|
-
else errors.push(createRequireError(arg, schema));
|
|
159
|
-
positionalsCount++;
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
170
|
for (let i = 0; i < optionTokens.length; i++) {
|
|
163
171
|
const token = optionTokens[i];
|
|
164
172
|
if (checkTokenName(arg, schema, token) && token.rawName != void 0 && hasLongOptionPrefix(token.rawName) || schema.short === token.name && token.rawName != void 0 && isShortOption(token.rawName)) {
|
package/lib/resolver.js
CHANGED
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.22.
|
|
4
|
+
"version": "0.22.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -72,33 +72,33 @@
|
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@eslint/markdown": "^6.6.0",
|
|
75
|
-
"@kazupon/eslint-config": "^0.
|
|
75
|
+
"@kazupon/eslint-config": "^0.33.0",
|
|
76
76
|
"@kazupon/prettier-config": "^0.1.1",
|
|
77
|
-
"@types/node": "^22.
|
|
78
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
77
|
+
"@types/node": "^22.17.0",
|
|
78
|
+
"@typescript/native-preview": "7.0.0-dev.20250731.1",
|
|
79
79
|
"@vitest/eslint-plugin": "^1.3.4",
|
|
80
|
-
"bumpp": "^10.2.
|
|
81
|
-
"deno": "^2.4.
|
|
82
|
-
"eslint": "^9.
|
|
83
|
-
"eslint-config-prettier": "^10.1.
|
|
80
|
+
"bumpp": "^10.2.1",
|
|
81
|
+
"deno": "^2.4.3",
|
|
82
|
+
"eslint": "^9.32.0",
|
|
83
|
+
"eslint-config-prettier": "^10.1.8",
|
|
84
84
|
"eslint-plugin-jsonc": "^2.20.1",
|
|
85
85
|
"eslint-plugin-promise": "^7.2.1",
|
|
86
86
|
"eslint-plugin-regexp": "^2.9.0",
|
|
87
|
-
"eslint-plugin-unicorn": "^
|
|
87
|
+
"eslint-plugin-unicorn": "^60.0.0",
|
|
88
88
|
"eslint-plugin-yml": "^1.18.0",
|
|
89
89
|
"gh-changelogen": "^0.2.8",
|
|
90
90
|
"jsr": "^0.13.5",
|
|
91
91
|
"jsr-exports-lint": "^0.4.1",
|
|
92
|
-
"knip": "^5.
|
|
92
|
+
"knip": "^5.62.0",
|
|
93
93
|
"lint-staged": "^16.1.2",
|
|
94
94
|
"mitata": "^1.0.34",
|
|
95
95
|
"pkg-pr-new": "^0.0.54",
|
|
96
96
|
"prettier": "^3.6.2",
|
|
97
|
-
"tsdown": "^0.
|
|
97
|
+
"tsdown": "^0.13.0",
|
|
98
98
|
"typescript": "^5.8.3",
|
|
99
|
-
"typescript-eslint": "^8.
|
|
99
|
+
"typescript-eslint": "^8.38.0",
|
|
100
100
|
"vitest": "^3.2.4",
|
|
101
|
-
"zod": "^4.0.
|
|
101
|
+
"zod": "^4.0.14"
|
|
102
102
|
},
|
|
103
103
|
"prettier": "@kazupon/prettier-config",
|
|
104
104
|
"lint-staged": {
|
|
@@ -124,12 +124,12 @@
|
|
|
124
124
|
"fix": "pnpm run --parallel --color \"/^fix:/\"",
|
|
125
125
|
"fix:eslint": "eslint . --fix",
|
|
126
126
|
"fix:knip": "knip --fix --no-exit-code",
|
|
127
|
-
"fix:prettier": "prettier . --write",
|
|
127
|
+
"fix:prettier": "prettier . --write --experimental-cli",
|
|
128
128
|
"lint": "pnpm run --parallel --color \"/^lint:/\"",
|
|
129
129
|
"lint:eslint": "eslint .",
|
|
130
130
|
"lint:jsr": "jsr publish --config jsr.json --dry-run --allow-dirty",
|
|
131
131
|
"lint:knip": "knip",
|
|
132
|
-
"lint:prettier": "prettier . --check",
|
|
132
|
+
"lint:prettier": "prettier . --check --experimental-cli",
|
|
133
133
|
"release": "bumpp --commit \"release: v%s\" --all --push --tag",
|
|
134
134
|
"test": "vitest run --typecheck",
|
|
135
135
|
"typecheck": "pnpm run --parallel --color \"/^typecheck:/\"",
|