@gunshi/shared 0.33.0 → 0.35.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 +36 -8
- package/lib/index.js +1 -1
- package/package.json +3 -3
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.27.0/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,13 +55,13 @@ 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.27.0/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.
|
|
62
62
|
*
|
|
63
63
|
* This schema is similar to the schema of Node.js `util.parseArgs` but with extended features:
|
|
64
|
-
* - Additional `required` and `
|
|
64
|
+
* - Additional `required`, `description`, and `hidden` properties
|
|
65
65
|
* - Extended `type` support: 'string', 'boolean', 'number', 'enum', 'positional', 'custom'
|
|
66
66
|
* - Simplified `default` property (single type, not union types)
|
|
67
67
|
*
|
|
@@ -166,13 +166,35 @@ interface ArgSchema {
|
|
|
166
166
|
* ```
|
|
167
167
|
*/
|
|
168
168
|
description?: string;
|
|
169
|
+
/**
|
|
170
|
+
* Hide the argument from generated help or usage output.
|
|
171
|
+
*
|
|
172
|
+
* This is metadata for renderers. It does not affect parsing, validation,
|
|
173
|
+
* required checks, defaults, conflicts, or resolved values.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* Hidden compatibility option:
|
|
177
|
+
* ```ts
|
|
178
|
+
* {
|
|
179
|
+
* legacy: {
|
|
180
|
+
* type: 'string',
|
|
181
|
+
* hidden: true,
|
|
182
|
+
* description: 'Deprecated compatibility option'
|
|
183
|
+
* }
|
|
184
|
+
* }
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
hidden?: boolean;
|
|
169
188
|
/**
|
|
170
189
|
* Marks the argument as required.
|
|
171
190
|
*
|
|
172
191
|
* When `true`, the argument must be provided by the user.
|
|
173
192
|
* If missing, an `ArgResolveError` with type 'required' will be thrown.
|
|
174
193
|
*
|
|
175
|
-
*
|
|
194
|
+
* For single-value positional arguments, omitting `required` keeps the argument
|
|
195
|
+
* required for compatibility. Set `required: false` to make a positional argument
|
|
196
|
+
* optional. Optional positional arguments leave enough input values for later
|
|
197
|
+
* required positional arguments before consuming a value.
|
|
176
198
|
*
|
|
177
199
|
* @example
|
|
178
200
|
* Required arguments:
|
|
@@ -196,7 +218,8 @@ interface ArgSchema {
|
|
|
196
218
|
*
|
|
197
219
|
* When `true`, the resolved value becomes an array.
|
|
198
220
|
* For options: can be specified multiple times (--tag foo --tag bar)
|
|
199
|
-
* For positional: collects remaining positional arguments
|
|
221
|
+
* For positional: collects remaining positional arguments after preserving values for
|
|
222
|
+
* later required positional arguments.
|
|
200
223
|
*
|
|
201
224
|
* Note: Only `true` is allowed (not `false`) to make intent explicit.
|
|
202
225
|
*
|
|
@@ -276,7 +299,11 @@ interface ArgSchema {
|
|
|
276
299
|
* - `boolean` type: boolean default
|
|
277
300
|
* - `number` type: number default
|
|
278
301
|
* - `enum` type: must be one of the `choices` values
|
|
279
|
-
* - `positional`/`custom` type:
|
|
302
|
+
* - `positional`/`custom` type: string, boolean, or number default
|
|
303
|
+
*
|
|
304
|
+
* For single-value positional arguments, the default is used when the positional
|
|
305
|
+
* value is missing or when the value is preserved for later required positional
|
|
306
|
+
* arguments, unless `required: true` is set.
|
|
280
307
|
*
|
|
281
308
|
* @example
|
|
282
309
|
* Default values by type:
|
|
@@ -533,7 +560,8 @@ type FilterArgs<A extends Args, V extends Record<keyof A, unknown>, K extends ke
|
|
|
533
560
|
*
|
|
534
561
|
* @internal
|
|
535
562
|
*/
|
|
536
|
-
type FilterPositionalArgs<A extends Args, V extends Record<keyof A, unknown>> = { [Arg in keyof A as A[Arg]
|
|
563
|
+
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] };
|
|
564
|
+
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
565
|
/**
|
|
538
566
|
* An arguments for {@link resolveArgs | resolve arguments}.
|
|
539
567
|
*/
|
|
@@ -1084,7 +1112,7 @@ type CommandExamplesFetcher<G extends GunshiParamsConstraint = DefaultGunshiPara
|
|
|
1084
1112
|
*/
|
|
1085
1113
|
type CommandRunner<G extends GunshiParamsConstraint = DefaultGunshiParams> = (ctx: Readonly<CommandContext<G>>) => Awaitable<string | void>;
|
|
1086
1114
|
//#endregion
|
|
1087
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
1115
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.27.0/node_modules/args-tokens/lib/utils.d.ts
|
|
1088
1116
|
//#region src/utils.d.ts
|
|
1089
1117
|
/**
|
|
1090
1118
|
* Entry point of utils.
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gunshi/shared",
|
|
3
3
|
"description": "shared utils for gunshi",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.35.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"jsr-exports-lint": "^0.4.2",
|
|
56
56
|
"publint": "^0.3.20",
|
|
57
57
|
"tsdown": "0.21.0",
|
|
58
|
-
"@gunshi/resources": "0.
|
|
59
|
-
"gunshi": "0.
|
|
58
|
+
"@gunshi/resources": "0.35.0",
|
|
59
|
+
"gunshi": "0.35.0"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsdown",
|