args-tokens 0.18.0 → 0.20.0
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-_BCsM-y_.js → resolver-Q4k2fgTW.js} +41 -43
- package/lib/{resolver-D_oOCXlX.d.ts → resolver-U72Jg6Ll.d.ts} +37 -20
- 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 +13 -12
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,4 +1,5 @@
|
|
|
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;
|
|
@@ -9,7 +10,7 @@ const SKIP_POSITIONAL_DEFAULT = -1;
|
|
|
9
10
|
* @param resolveArgs - An arguments that contains {@link ResolveArgs | resolve arguments}.
|
|
10
11
|
* @returns An object that contains the values of the arguments, positional arguments, rest arguments, and {@link AggregateError | validation errors}.
|
|
11
12
|
*/
|
|
12
|
-
function resolveArgs(args, tokens, {
|
|
13
|
+
function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKIP_POSITIONAL_DEFAULT, toKebab = false } = {}) {
|
|
13
14
|
const skipPositionalIndex = typeof skipPositional === "number" ? Math.max(skipPositional, SKIP_POSITIONAL_DEFAULT) : SKIP_POSITIONAL_DEFAULT;
|
|
14
15
|
const rest = [];
|
|
15
16
|
const optionTokens = [];
|
|
@@ -68,7 +69,7 @@ function resolveArgs(args, tokens, { optionGrouping = false, skipPositional = SK
|
|
|
68
69
|
else currentLongOption = { ...token };
|
|
69
70
|
applyShortOptionValue();
|
|
70
71
|
} else if (isShortOption(token.rawName)) if (currentShortOption) {
|
|
71
|
-
if (currentShortOption.index === token.index) if (
|
|
72
|
+
if (currentShortOption.index === token.index) if (shortGrouping) {
|
|
72
73
|
currentShortOption.value = token.value;
|
|
73
74
|
optionTokens.push({ ...currentShortOption });
|
|
74
75
|
currentShortOption = { ...token };
|
|
@@ -115,48 +116,43 @@ function resolveArgs(args, tokens, { optionGrouping = false, skipPositional = SK
|
|
|
115
116
|
return Math.min(skipPositionalIndex, positionalItemCount);
|
|
116
117
|
}
|
|
117
118
|
let positionalsCount = 0;
|
|
118
|
-
for (const [
|
|
119
|
+
for (const [rawArg, schema] of Object.entries(args)) {
|
|
120
|
+
const arg = toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
|
|
119
121
|
if (schema.required) {
|
|
120
122
|
const found = optionTokens.find((token) => {
|
|
121
|
-
return schema.short && token.name === schema.short || token.rawName && hasLongOptionPrefix(token.rawName) && token.name ===
|
|
123
|
+
return schema.short && token.name === schema.short || token.rawName && hasLongOptionPrefix(token.rawName) && token.name === arg;
|
|
122
124
|
});
|
|
123
125
|
if (!found) {
|
|
124
|
-
errors.push(createRequireError(
|
|
126
|
+
errors.push(createRequireError(arg, schema));
|
|
125
127
|
continue;
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
if (schema.type === "positional") {
|
|
129
131
|
if (skipPositionalIndex > SKIP_POSITIONAL_DEFAULT) while (positionalsCount <= getPositionalSkipIndex()) positionalsCount++;
|
|
130
132
|
const positional = positionalTokens[positionalsCount];
|
|
131
|
-
if (positional != null) values[
|
|
132
|
-
else errors.push(createRequireError(
|
|
133
|
+
if (positional != null) values[rawArg] = positional.value;
|
|
134
|
+
else errors.push(createRequireError(arg, schema));
|
|
133
135
|
positionalsCount++;
|
|
134
136
|
continue;
|
|
135
137
|
}
|
|
136
138
|
for (let i = 0; i < optionTokens.length; i++) {
|
|
137
139
|
const token = optionTokens[i];
|
|
138
|
-
if (checkTokenName(
|
|
139
|
-
const invalid = validateRequire(token,
|
|
140
|
+
if (checkTokenName(arg, schema, token) && token.rawName != void 0 && hasLongOptionPrefix(token.rawName) || schema.short === token.name && token.rawName != void 0 && isShortOption(token.rawName)) {
|
|
141
|
+
const invalid = validateRequire(token, arg, schema);
|
|
140
142
|
if (invalid) {
|
|
141
143
|
errors.push(invalid);
|
|
142
144
|
continue;
|
|
143
145
|
}
|
|
144
146
|
if (schema.type === "boolean") token.value = void 0;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
if (schema.multiple) {
|
|
153
|
-
values[option] ||= [];
|
|
154
|
-
values[option].push(resolveArgumentValue(token, schema));
|
|
155
|
-
} else values[option] = resolveArgumentValue(token, schema);
|
|
156
|
-
continue;
|
|
147
|
+
const [parsedValue, error] = parse(token, arg, schema);
|
|
148
|
+
if (error) errors.push(error);
|
|
149
|
+
else if (schema.multiple) {
|
|
150
|
+
values[rawArg] ||= [];
|
|
151
|
+
values[rawArg].push(parsedValue);
|
|
152
|
+
} else values[rawArg] = parsedValue;
|
|
157
153
|
}
|
|
158
154
|
}
|
|
159
|
-
if (values[
|
|
155
|
+
if (values[rawArg] == null && schema.default != null) values[rawArg] = schema.default;
|
|
160
156
|
}
|
|
161
157
|
return {
|
|
162
158
|
values,
|
|
@@ -165,6 +161,29 @@ function resolveArgs(args, tokens, { optionGrouping = false, skipPositional = SK
|
|
|
165
161
|
error: errors.length > 0 ? new AggregateError(errors) : void 0
|
|
166
162
|
};
|
|
167
163
|
}
|
|
164
|
+
function parse(token, option, schema) {
|
|
165
|
+
switch (schema.type) {
|
|
166
|
+
case "string": return typeof token.value === "string" ? [token.value || schema.default, void 0] : [void 0, createTypeError(option, schema)];
|
|
167
|
+
case "boolean": return token.value ? [token.value || schema.default, void 0] : [!(schema.negatable && token.name.startsWith("no-")), void 0];
|
|
168
|
+
case "number": {
|
|
169
|
+
if (!isNumeric(token.value)) return [void 0, createTypeError(option, schema)];
|
|
170
|
+
return token.value ? [+token.value, void 0] : [+(schema.default || ""), void 0];
|
|
171
|
+
}
|
|
172
|
+
case "enum": {
|
|
173
|
+
if (schema.choices && !schema.choices.includes(token.value)) return [void 0, new ArgResolveError(`Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}should be chosen from '${schema.type}' [${schema.choices.map((c) => JSON.stringify(c)).join(", ")}] values`, option, "type", schema)];
|
|
174
|
+
return [token.value || schema.default, void 0];
|
|
175
|
+
}
|
|
176
|
+
case "custom": {
|
|
177
|
+
if (typeof schema.parse !== "function") throw new TypeError(`argument '${option}' should have a 'parse' function`);
|
|
178
|
+
try {
|
|
179
|
+
return [schema.parse(token.value || String(schema.default || "")), void 0];
|
|
180
|
+
} catch (error) {
|
|
181
|
+
return [void 0, error];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
default: throw new Error(`Unsupported argument type '${schema.type}' for option '${option}'`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
168
187
|
function createRequireError(option, schema) {
|
|
169
188
|
const message = schema.type === "positional" ? `Positional argument '${option}' is required` : `Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}is required`;
|
|
170
189
|
return new ArgResolveError(message, option, "required", schema);
|
|
@@ -187,33 +206,12 @@ var ArgResolveError = class extends Error {
|
|
|
187
206
|
function validateRequire(token, option, schema) {
|
|
188
207
|
if (schema.required && schema.type !== "boolean" && !token.value) return createRequireError(option, schema);
|
|
189
208
|
}
|
|
190
|
-
function validateValue(token, option, schema) {
|
|
191
|
-
switch (schema.type) {
|
|
192
|
-
case "number": {
|
|
193
|
-
if (!isNumeric(token.value)) return createTypeError(option, schema);
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
case "string": {
|
|
197
|
-
if (typeof token.value !== "string") return createTypeError(option, schema);
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
case "enum": {
|
|
201
|
-
if (schema.choices && !schema.choices.includes(token.value)) return new ArgResolveError(`Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}should be chosen from '${schema.type}' [${schema.choices.map((c) => JSON.stringify(c)).join(", ")}] values`, option, "type", schema);
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
209
|
function isNumeric(str) {
|
|
207
210
|
return str.trim() !== "" && !isNaN(str);
|
|
208
211
|
}
|
|
209
212
|
function createTypeError(option, schema) {
|
|
210
213
|
return new ArgResolveError(`Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}should be '${schema.type}'`, option, "type", schema);
|
|
211
214
|
}
|
|
212
|
-
function resolveArgumentValue(token, schema) {
|
|
213
|
-
if (token.value) return schema.type === "number" ? +token.value : token.value;
|
|
214
|
-
if (schema.type === "boolean") return schema.negatable && token.name.startsWith("no-") ? false : true;
|
|
215
|
-
return schema.type === "number" ? +(schema.default || "") : schema.default;
|
|
216
|
-
}
|
|
217
215
|
|
|
218
216
|
//#endregion
|
|
219
217
|
export { ArgResolveError, resolveArgs };
|
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
import { ArgToken } from "./parser-
|
|
1
|
+
import { ArgToken } from "./parser-FiQIAw-2.js";
|
|
2
2
|
|
|
3
3
|
//#region src/resolver.d.ts
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* An argument schema
|
|
6
7
|
* This schema is similar to the schema of the `node:utils`.
|
|
7
8
|
* difference is that:
|
|
8
9
|
* - `required` property and `description` property are added
|
|
9
|
-
* - `type` is not only 'string' and 'boolean', but also 'number', 'enum'
|
|
10
|
-
* - `default` property type, not support multiple types
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* An argument schema
|
|
14
|
-
* This schema is similar to the schema of the `node:utils`.
|
|
15
|
-
* difference is that:
|
|
16
|
-
* - `required` property and `description` property are added
|
|
17
|
-
* - `type` is not only 'string' and 'boolean', but also 'number', 'enum' and 'positional' too.
|
|
10
|
+
* - `type` is not only 'string' and 'boolean', but also 'number', 'enum', 'positional', 'custom' too.
|
|
18
11
|
* - `default` property type, not support multiple types
|
|
19
12
|
*/
|
|
20
13
|
interface ArgSchema {
|
|
21
14
|
/**
|
|
22
15
|
* Type of argument.
|
|
23
16
|
*/
|
|
24
|
-
type: "string" | "boolean" | "number" | "enum" | "positional";
|
|
17
|
+
type: "string" | "boolean" | "number" | "enum" | "positional" | "custom";
|
|
25
18
|
/**
|
|
26
|
-
* A single character alias for the
|
|
19
|
+
* A single character alias for the argument.
|
|
27
20
|
*/
|
|
28
21
|
short?: string;
|
|
29
22
|
/**
|
|
@@ -51,6 +44,19 @@ interface ArgSchema {
|
|
|
51
44
|
* if the type is 'enum', the default value must be one of the allowed values.
|
|
52
45
|
*/
|
|
53
46
|
default?: string | boolean | number;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to convert the argument name to kebab-case.
|
|
49
|
+
*/
|
|
50
|
+
toKebab?: true;
|
|
51
|
+
/**
|
|
52
|
+
* A function to parse the value of the argument. if the type is 'custom', this function is required.
|
|
53
|
+
* If argument value will be invalid, this function have to throw an error.
|
|
54
|
+
* @param value
|
|
55
|
+
* @returns Parsed value
|
|
56
|
+
* @throws An Error, If the value is invalid. Error type should be `Error` or extends it
|
|
57
|
+
*/
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
parse?: (value: string) => any;
|
|
54
60
|
}
|
|
55
61
|
/**
|
|
56
62
|
* An object that contains {@link ArgSchema | argument schema}.
|
|
@@ -64,34 +70,45 @@ interface Args {
|
|
|
64
70
|
type ArgValues<T> = T extends Args ? ResolveArgValues<T, { [Arg in keyof T]: ExtractOptionValue<T[Arg]> }> : {
|
|
65
71
|
[option: string]: string | boolean | number | (string | boolean | number)[] | undefined;
|
|
66
72
|
};
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
type IsFunction<T> = T extends ((...args: any[]) => any) ? true : false;
|
|
67
75
|
/**
|
|
68
76
|
* @internal
|
|
69
77
|
*/
|
|
70
|
-
type ExtractOptionValue<A extends ArgSchema> = A["type"] extends "string" ? ResolveOptionValue<A, string> : A["type"] extends "boolean" ? ResolveOptionValue<A, boolean> : A["type"] extends "number" ? ResolveOptionValue<A, number> : A["type"] extends "positional" ? ResolveOptionValue<A, string> : A["type"] extends "enum" ? A["choices"] extends string[] | readonly string[] ? ResolveOptionValue<A, A["choices"][number]> : never : ResolveOptionValue<A, string | boolean | number>;
|
|
78
|
+
type ExtractOptionValue<A extends ArgSchema> = A["type"] extends "string" ? ResolveOptionValue<A, string> : A["type"] extends "boolean" ? ResolveOptionValue<A, boolean> : A["type"] extends "number" ? ResolveOptionValue<A, number> : A["type"] extends "positional" ? ResolveOptionValue<A, string> : A["type"] extends "enum" ? A["choices"] extends string[] | readonly string[] ? ResolveOptionValue<A, A["choices"][number]> : never : A["type"] extends "custom" ? IsFunction<A["parse"]> extends true ? ResolveOptionValue<A, ReturnType<NonNullable<A["parse"]>>> : never : ResolveOptionValue<A, string | boolean | number>;
|
|
71
79
|
type ResolveOptionValue<A extends ArgSchema, T> = A["multiple"] extends true ? T[] : T;
|
|
72
80
|
/**
|
|
73
81
|
* @internal
|
|
74
82
|
*/
|
|
75
|
-
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;
|
|
76
84
|
/**
|
|
77
85
|
* @internal
|
|
78
86
|
*/
|
|
79
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] };
|
|
80
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
|
+
/**
|
|
81
93
|
* An arguments for {@link resolveArgs | resolve arguments}.
|
|
82
94
|
*/
|
|
83
95
|
interface ResolveArgs {
|
|
84
96
|
/**
|
|
85
|
-
* Whether to group short
|
|
97
|
+
* Whether to group short arguments.
|
|
86
98
|
* @default false
|
|
87
99
|
* @see guideline 5 in https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap12.html
|
|
88
100
|
*/
|
|
89
|
-
|
|
101
|
+
shortGrouping?: boolean;
|
|
90
102
|
/**
|
|
91
103
|
* Skip positional arguments index.
|
|
92
104
|
* @default -1
|
|
93
105
|
*/
|
|
94
106
|
skipPositional?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Whether to convert the argument name to kebab-case. This option is applied to all arguments as `toKebab: true`, if set to `true`.
|
|
109
|
+
* @default false
|
|
110
|
+
*/
|
|
111
|
+
toKebab?: boolean;
|
|
95
112
|
}
|
|
96
113
|
/**
|
|
97
114
|
* Resolve command line arguments.
|
|
@@ -101,8 +118,9 @@ interface ResolveArgs {
|
|
|
101
118
|
* @returns An object that contains the values of the arguments, positional arguments, rest arguments, and {@link AggregateError | validation errors}.
|
|
102
119
|
*/
|
|
103
120
|
declare function resolveArgs<A extends Args>(args: A, tokens: ArgToken[], {
|
|
104
|
-
|
|
105
|
-
skipPositional
|
|
121
|
+
shortGrouping,
|
|
122
|
+
skipPositional,
|
|
123
|
+
toKebab
|
|
106
124
|
}?: ResolveArgs): {
|
|
107
125
|
values: ArgValues<A>;
|
|
108
126
|
positionals: string[];
|
|
@@ -123,6 +141,5 @@ declare class ArgResolveError extends Error {
|
|
|
123
141
|
type: ArgResolveErrorType;
|
|
124
142
|
constructor(message: string, name: string, type: ArgResolveErrorType, schema: ArgSchema);
|
|
125
143
|
}
|
|
126
|
-
|
|
127
144
|
//#endregion
|
|
128
|
-
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.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"@eslint/markdown": "^6.4.0",
|
|
69
69
|
"@kazupon/eslint-config": "^0.29.0",
|
|
70
70
|
"@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.
|
|
71
|
+
"@types/node": "^22.15.27",
|
|
72
|
+
"@typescript/native-preview": "7.0.0-dev.20250529.1",
|
|
73
|
+
"@vitest/eslint-plugin": "^1.2.1",
|
|
74
74
|
"bumpp": "^10.1.1",
|
|
75
|
-
"deno": "^2.3.
|
|
75
|
+
"deno": "^2.3.4",
|
|
76
76
|
"eslint": "^9.27.0",
|
|
77
77
|
"eslint-config-prettier": "^10.1.5",
|
|
78
78
|
"eslint-plugin-jsonc": "^2.20.1",
|
|
@@ -83,15 +83,16 @@
|
|
|
83
83
|
"gh-changelogen": "^0.2.8",
|
|
84
84
|
"jsr": "^0.13.4",
|
|
85
85
|
"jsr-exports-lint": "^0.4.0",
|
|
86
|
-
"knip": "^5.
|
|
87
|
-
"lint-staged": "^
|
|
86
|
+
"knip": "^5.59.1",
|
|
87
|
+
"lint-staged": "^16.0.0",
|
|
88
88
|
"mitata": "^1.0.34",
|
|
89
|
-
"pkg-pr-new": "^0.0.
|
|
89
|
+
"pkg-pr-new": "^0.0.51",
|
|
90
90
|
"prettier": "^3.5.3",
|
|
91
|
-
"tsdown": "^0.12.
|
|
91
|
+
"tsdown": "^0.12.4",
|
|
92
92
|
"typescript": "^5.8.3",
|
|
93
|
-
"typescript-eslint": "^8.
|
|
94
|
-
"vitest": "^3.1.4"
|
|
93
|
+
"typescript-eslint": "^8.33.0",
|
|
94
|
+
"vitest": "^3.1.4",
|
|
95
|
+
"zod": "^3.25.41"
|
|
95
96
|
},
|
|
96
97
|
"prettier": "@kazupon/prettier-config",
|
|
97
98
|
"lint-staged": {
|
|
@@ -124,7 +125,7 @@
|
|
|
124
125
|
"lint:knip": "knip",
|
|
125
126
|
"lint:prettier": "prettier . --check",
|
|
126
127
|
"release": "bumpp --commit \"release: v%s\" --all --push --tag",
|
|
127
|
-
"test": "vitest run",
|
|
128
|
+
"test": "vitest run --typecheck",
|
|
128
129
|
"typecheck": "pnpm run --parallel --color \"/^typecheck:/\"",
|
|
129
130
|
"typecheck:deno": "deno check src",
|
|
130
131
|
"typecheck:tsc": "tsgo --noEmit"
|