@gunshi/definition 0.33.0 → 0.34.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 +15 -6
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
1
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.26.1/node_modules/args-tokens/lib/parser-DT7Ztcch.d.ts
|
|
2
2
|
//#region src/parser.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Entry point of argument parser.
|
|
@@ -55,7 +55,7 @@ interface ArgToken {
|
|
|
55
55
|
* Parser Options.
|
|
56
56
|
*/
|
|
57
57
|
//#endregion
|
|
58
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
58
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.26.1/node_modules/args-tokens/lib/resolver.d.ts
|
|
59
59
|
//#region src/resolver.d.ts
|
|
60
60
|
/**
|
|
61
61
|
* An argument schema definition for command-line argument parsing.
|
|
@@ -172,7 +172,10 @@ interface ArgSchema {
|
|
|
172
172
|
* When `true`, the argument must be provided by the user.
|
|
173
173
|
* If missing, an `ArgResolveError` with type 'required' will be thrown.
|
|
174
174
|
*
|
|
175
|
-
*
|
|
175
|
+
* For single-value positional arguments, omitting `required` keeps the argument
|
|
176
|
+
* required for compatibility. Set `required: false` to make a positional argument
|
|
177
|
+
* optional. Optional positional arguments leave enough input values for later
|
|
178
|
+
* required positional arguments before consuming a value.
|
|
176
179
|
*
|
|
177
180
|
* @example
|
|
178
181
|
* Required arguments:
|
|
@@ -196,7 +199,8 @@ interface ArgSchema {
|
|
|
196
199
|
*
|
|
197
200
|
* When `true`, the resolved value becomes an array.
|
|
198
201
|
* For options: can be specified multiple times (--tag foo --tag bar)
|
|
199
|
-
* For positional: collects remaining positional arguments
|
|
202
|
+
* For positional: collects remaining positional arguments after preserving values for
|
|
203
|
+
* later required positional arguments.
|
|
200
204
|
*
|
|
201
205
|
* Note: Only `true` is allowed (not `false`) to make intent explicit.
|
|
202
206
|
*
|
|
@@ -276,7 +280,11 @@ interface ArgSchema {
|
|
|
276
280
|
* - `boolean` type: boolean default
|
|
277
281
|
* - `number` type: number default
|
|
278
282
|
* - `enum` type: must be one of the `choices` values
|
|
279
|
-
* - `positional`/`custom` type:
|
|
283
|
+
* - `positional`/`custom` type: string, boolean, or number default
|
|
284
|
+
*
|
|
285
|
+
* For single-value positional arguments, the default is used when the positional
|
|
286
|
+
* value is missing or when the value is preserved for later required positional
|
|
287
|
+
* arguments, unless `required: true` is set.
|
|
280
288
|
*
|
|
281
289
|
* @example
|
|
282
290
|
* Default values by type:
|
|
@@ -533,7 +541,8 @@ type FilterArgs<A extends Args, V extends Record<keyof A, unknown>, K extends ke
|
|
|
533
541
|
*
|
|
534
542
|
* @internal
|
|
535
543
|
*/
|
|
536
|
-
type FilterPositionalArgs<A extends Args, V extends Record<keyof A, unknown>> = { [Arg in keyof A as A[Arg]
|
|
544
|
+
type FilterPositionalArgs<A extends Args, V extends Record<keyof A, unknown>> = { [Arg in keyof A as IsRequiredPositionalArg<A[Arg]> extends true ? Arg : never]: V[Arg] };
|
|
545
|
+
type IsRequiredPositionalArg<A extends ArgSchema> = A['type'] extends 'positional' ? A['multiple'] extends true ? A['required'] extends true ? true : false : A['required'] extends false ? A['default'] extends {} ? true : false : true : false;
|
|
537
546
|
/**
|
|
538
547
|
* An arguments for {@link resolveArgs | resolve arguments}.
|
|
539
548
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gunshi/definition",
|
|
3
3
|
"description": "utilities for gunshi command definition",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.34.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"jsr-exports-lint": "^0.4.2",
|
|
58
58
|
"publint": "^0.3.20",
|
|
59
59
|
"tsdown": "0.21.0",
|
|
60
|
-
"gunshi": "0.
|
|
60
|
+
"gunshi": "0.34.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsdown",
|