@gunshi/shared 0.28.2 → 0.29.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 +28 -7
- 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.24.1/node_modules/args-tokens/lib/parser-DH5KtXsI.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.24.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.
|
|
@@ -190,7 +190,7 @@ interface ArgSchema {
|
|
|
190
190
|
* }
|
|
191
191
|
* ```
|
|
192
192
|
*/
|
|
193
|
-
required?:
|
|
193
|
+
required?: boolean;
|
|
194
194
|
/**
|
|
195
195
|
* Allows the argument to accept multiple values.
|
|
196
196
|
*
|
|
@@ -417,6 +417,28 @@ interface ArgSchema {
|
|
|
417
417
|
* ```
|
|
418
418
|
*/
|
|
419
419
|
conflicts?: string | string[];
|
|
420
|
+
/**
|
|
421
|
+
* Display name hint for help text generation.
|
|
422
|
+
*
|
|
423
|
+
* Provides a meaningful type hint for the argument value in help output.
|
|
424
|
+
* Particularly useful for `type: 'custom'` arguments where the type
|
|
425
|
+
* name would otherwise be unhelpful.
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* Metavar usage:
|
|
429
|
+
* ```ts
|
|
430
|
+
* {
|
|
431
|
+
* port: {
|
|
432
|
+
* type: 'custom',
|
|
433
|
+
* parse: (v: string) => parseInt(v, 10),
|
|
434
|
+
* metavar: 'integer',
|
|
435
|
+
* description: 'Port number (1-65535)'
|
|
436
|
+
* }
|
|
437
|
+
* }
|
|
438
|
+
* // Help output: --port <integer> Port number (1-65535)
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
441
|
+
metavar?: string;
|
|
420
442
|
/**
|
|
421
443
|
* Custom parsing function for `type: 'custom'` arguments.
|
|
422
444
|
*
|
|
@@ -475,7 +497,6 @@ interface Args {
|
|
|
475
497
|
type ArgValues<T> = T extends Args ? ResolveArgValues<T, { [Arg in keyof T]: ExtractOptionValue<T[Arg]> }> : {
|
|
476
498
|
[option: string]: string | boolean | number | (string | boolean | number)[] | undefined;
|
|
477
499
|
};
|
|
478
|
-
type IsFunction<T> = T extends ((...args: any[]) => any) ? true : false;
|
|
479
500
|
/**
|
|
480
501
|
* Extracts the value type from the argument schema.
|
|
481
502
|
*
|
|
@@ -483,7 +504,7 @@ type IsFunction<T> = T extends ((...args: any[]) => any) ? true : false;
|
|
|
483
504
|
*
|
|
484
505
|
* @internal
|
|
485
506
|
*/
|
|
486
|
-
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' ?
|
|
507
|
+
type ExtractOptionValue<A extends ArgSchema> = undefined extends A['parse'] ? 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' ? never : ResolveOptionValue<A, string | boolean | number> : A['parse'] extends ((value: string) => infer R) ? ResolveOptionValue<A, R> : never;
|
|
487
508
|
type ResolveOptionValue<A extends ArgSchema, T> = A['multiple'] extends true ? T[] : T;
|
|
488
509
|
/**
|
|
489
510
|
* Resolved argument values.
|
|
@@ -503,7 +524,7 @@ type ResolveArgValues<A extends Args, V extends Record<keyof A, unknown>> = { -r
|
|
|
503
524
|
*
|
|
504
525
|
* @internal
|
|
505
526
|
*/
|
|
506
|
-
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] };
|
|
527
|
+
type FilterArgs<A extends Args, V extends Record<keyof A, unknown>, K extends keyof ArgSchema> = { [Arg in keyof A as K extends 'required' ? A[Arg][K] extends true ? Arg : never : A[Arg][K] extends {} ? Arg : never]: V[Arg] };
|
|
507
528
|
/**
|
|
508
529
|
* Filters positional arguments from the argument schema.
|
|
509
530
|
*
|
|
@@ -1063,7 +1084,7 @@ type CommandExamplesFetcher<G extends GunshiParamsConstraint = DefaultGunshiPara
|
|
|
1063
1084
|
*/
|
|
1064
1085
|
type CommandRunner<G extends GunshiParamsConstraint = DefaultGunshiParams> = (ctx: Readonly<CommandContext<G>>) => Awaitable<string | void>;
|
|
1065
1086
|
//#endregion
|
|
1066
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
1087
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.24.1/node_modules/args-tokens/lib/utils.d.ts
|
|
1067
1088
|
//#region src/utils.d.ts
|
|
1068
1089
|
/**
|
|
1069
1090
|
* 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.29.1",
|
|
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.1",
|
|
56
56
|
"publint": "^0.3.16",
|
|
57
57
|
"tsdown": "0.15.12",
|
|
58
|
-
"@gunshi/resources": "0.
|
|
59
|
-
"gunshi": "0.
|
|
58
|
+
"@gunshi/resources": "0.29.1",
|
|
59
|
+
"gunshi": "0.29.1"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsdown",
|