gunshi 0.34.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/bone.d.ts +2 -2
- package/lib/bone.js +1 -1
- package/lib/{cli-CS4q7S8l.js → cli-DoX4INTi.js} +3 -3
- package/lib/combinators.d.ts +34 -3
- package/lib/combinators.js +56 -20
- package/lib/{constants-Dmeogxy-.d.ts → constants-BkgP86Yw.d.ts} +1 -1
- package/lib/context.d.ts +2 -2
- package/lib/context.js +2 -2
- package/lib/{core-C83Uo6wC.js → core-xgWIcbHL.js} +54 -30
- package/lib/definition.d.ts +26 -17
- package/lib/definition.js +4 -4
- package/lib/generator.d.ts +1 -1
- package/lib/generator.js +2 -2
- package/lib/index.d.ts +3 -3
- package/lib/index.js +5 -5
- package/lib/plugin.d.ts +3 -3
- package/lib/plugin.js +2 -2
- package/lib/renderer.d.ts +1 -1
- package/lib/renderer.js +1 -1
- package/lib/{resolver-eOZBRWlR.d.ts → resolver-mxPNDBm_.d.ts} +22 -3
- package/lib/{src-Cs21MA7o.js → src-B4uHG_qb.js} +27 -14
- package/lib/{types-DZ8CuO6z.d.ts → types-DZ0S_FSe.d.ts} +1 -1
- package/lib/{utils-9CtzCGbg.js → utils-DNVHO9MQ.js} +1 -1
- package/lib/utils.d.ts +2 -2
- package/lib/utils.js +1 -1
- package/package.json +7 -7
- /package/lib/{constants-D_ixLD32.js → constants-CQq1R_68.js} +0 -0
- /package/lib/{core-D1daCTTE.js → core-CFEvRYOJ.js} +0 -0
package/lib/bone.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues } from "./resolver-
|
|
2
|
-
import { C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, O as ValidationErrorsDecorator, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues } from "./resolver-mxPNDBm_.js";
|
|
2
|
+
import { C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, O as ValidationErrorsDecorator, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-DZ0S_FSe.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/bone.d.ts
|
|
5
5
|
/**
|
package/lib/bone.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as plugin } from "./core-
|
|
2
|
-
import { a as namespacedId, o as COMMON_ARGS, t as renderer } from "./src-
|
|
3
|
-
import { t as cliCore } from "./core-
|
|
1
|
+
import { t as plugin } from "./core-CFEvRYOJ.js";
|
|
2
|
+
import { a as namespacedId, o as COMMON_ARGS, t as renderer } from "./src-B4uHG_qb.js";
|
|
3
|
+
import { t as cliCore } from "./core-xgWIcbHL.js";
|
|
4
4
|
//#region ../plugin-global/src/types.ts
|
|
5
5
|
/**
|
|
6
6
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
package/lib/combinators.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema } from "./resolver-
|
|
1
|
+
import { i as Args, n as ArgSchema } from "./resolver-mxPNDBm_.js";
|
|
2
2
|
|
|
3
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
3
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.27.0/node_modules/args-tokens/lib/combinators.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
6
6
|
* @license MIT
|
|
@@ -46,6 +46,10 @@ interface BaseOptions {
|
|
|
46
46
|
* Human-readable description for help text generation.
|
|
47
47
|
*/
|
|
48
48
|
description?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Hide from generated help or usage output.
|
|
51
|
+
*/
|
|
52
|
+
hidden?: boolean;
|
|
49
53
|
/**
|
|
50
54
|
* Single character short alias.
|
|
51
55
|
*/
|
|
@@ -504,6 +508,33 @@ type CombinatorDescribe<D extends string> = {
|
|
|
504
508
|
* @experimental
|
|
505
509
|
*/
|
|
506
510
|
declare function describe<T, D extends string>(schema: CombinatorSchema<T>, text: D): CombinatorSchema<T> & CombinatorDescribe<D>;
|
|
511
|
+
/**
|
|
512
|
+
* Options for the {@link hidden} combinator.
|
|
513
|
+
*/
|
|
514
|
+
type CombinatorHidden = {
|
|
515
|
+
hidden: true;
|
|
516
|
+
};
|
|
517
|
+
/**
|
|
518
|
+
* Hide a combinator schema from generated help or usage output.
|
|
519
|
+
*
|
|
520
|
+
* The original schema is not modified. This only marks renderer metadata and
|
|
521
|
+
* does not change parsing, validation, defaults, conflicts, or resolved values.
|
|
522
|
+
*
|
|
523
|
+
* @typeParam T - The schema type.
|
|
524
|
+
*
|
|
525
|
+
* @param schema - The base combinator schema.
|
|
526
|
+
* @returns A new schema with `hidden: true`.
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* ```ts
|
|
530
|
+
* const args = {
|
|
531
|
+
* legacy: hidden(string())
|
|
532
|
+
* }
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* @experimental
|
|
536
|
+
*/
|
|
537
|
+
declare function hidden<T extends ArgSchema>(schema: T): Omit<T, 'hidden'> & CombinatorHidden;
|
|
507
538
|
/**
|
|
508
539
|
* Options for the {@link unrequired} combinator.
|
|
509
540
|
*/
|
|
@@ -647,4 +678,4 @@ declare function extend<T extends Args, U extends Args>(base: T, overrides: U):
|
|
|
647
678
|
*/
|
|
648
679
|
|
|
649
680
|
//#endregion
|
|
650
|
-
export { type BaseOptions, type BooleanOptions, type Combinator, type CombinatorOptions, type CombinatorSchema, type FloatOptions, type IntegerOptions, type NumberOptions, type StringOptions, args, boolean, choice, combinator, describe, extend, float, integer, map, merge, multiple, number, positional, required, short, string, unrequired, withDefault };
|
|
681
|
+
export { type BaseOptions, type BooleanOptions, type Combinator, type CombinatorOptions, type CombinatorSchema, type FloatOptions, type IntegerOptions, type NumberOptions, type StringOptions, args, boolean, choice, combinator, describe, extend, float, hidden, integer, map, merge, multiple, number, positional, required, short, string, unrequired, withDefault };
|
package/lib/combinators.js
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/combinators.js
|
|
2
2
|
/**
|
|
3
3
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
4
4
|
* @license MIT
|
|
@@ -18,12 +18,13 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @experimental
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
// @__NO_SIDE_EFFECTS__
|
|
22
22
|
function string(opts) {
|
|
23
23
|
return {
|
|
24
24
|
type: "string",
|
|
25
25
|
metavar: "string",
|
|
26
26
|
...opts?.description != null ? { description: opts.description } : {},
|
|
27
|
+
...opts?.hidden != null ? { hidden: opts.hidden } : {},
|
|
27
28
|
...opts?.short != null ? { short: opts.short } : {},
|
|
28
29
|
...opts?.required != null ? { required: opts.required } : {},
|
|
29
30
|
parse(value) {
|
|
@@ -51,12 +52,13 @@ function string(opts) {
|
|
|
51
52
|
*
|
|
52
53
|
* @experimental
|
|
53
54
|
*/
|
|
54
|
-
|
|
55
|
+
// @__NO_SIDE_EFFECTS__
|
|
55
56
|
function number(opts) {
|
|
56
57
|
return {
|
|
57
58
|
type: "number",
|
|
58
59
|
metavar: "number",
|
|
59
60
|
...opts?.description != null ? { description: opts.description } : {},
|
|
61
|
+
...opts?.hidden != null ? { hidden: opts.hidden } : {},
|
|
60
62
|
...opts?.short != null ? { short: opts.short } : {},
|
|
61
63
|
...opts?.required != null ? { required: opts.required } : {},
|
|
62
64
|
parse(value) {
|
|
@@ -85,12 +87,13 @@ function number(opts) {
|
|
|
85
87
|
*
|
|
86
88
|
* @experimental
|
|
87
89
|
*/
|
|
88
|
-
|
|
90
|
+
// @__NO_SIDE_EFFECTS__
|
|
89
91
|
function integer(opts) {
|
|
90
92
|
return {
|
|
91
93
|
type: "custom",
|
|
92
94
|
metavar: "integer",
|
|
93
95
|
...opts?.description != null ? { description: opts.description } : {},
|
|
96
|
+
...opts?.hidden != null ? { hidden: opts.hidden } : {},
|
|
94
97
|
...opts?.short != null ? { short: opts.short } : {},
|
|
95
98
|
...opts?.required != null ? { required: opts.required } : {},
|
|
96
99
|
parse(value) {
|
|
@@ -120,12 +123,13 @@ function integer(opts) {
|
|
|
120
123
|
*
|
|
121
124
|
* @experimental
|
|
122
125
|
*/
|
|
123
|
-
|
|
126
|
+
// @__NO_SIDE_EFFECTS__
|
|
124
127
|
function float(opts) {
|
|
125
128
|
return {
|
|
126
129
|
type: "custom",
|
|
127
130
|
metavar: "float",
|
|
128
131
|
...opts?.description != null ? { description: opts.description } : {},
|
|
132
|
+
...opts?.hidden != null ? { hidden: opts.hidden } : {},
|
|
129
133
|
...opts?.short != null ? { short: opts.short } : {},
|
|
130
134
|
...opts?.required != null ? { required: opts.required } : {},
|
|
131
135
|
parse(value) {
|
|
@@ -158,13 +162,14 @@ function float(opts) {
|
|
|
158
162
|
*
|
|
159
163
|
* @experimental
|
|
160
164
|
*/
|
|
161
|
-
|
|
165
|
+
// @__NO_SIDE_EFFECTS__
|
|
162
166
|
function boolean(opts) {
|
|
163
167
|
return {
|
|
164
168
|
type: "boolean",
|
|
165
169
|
...opts?.negatable != null ? { negatable: opts.negatable } : {},
|
|
166
170
|
metavar: "boolean",
|
|
167
171
|
...opts?.description != null ? { description: opts.description } : {},
|
|
172
|
+
...opts?.hidden != null ? { hidden: opts.hidden } : {},
|
|
168
173
|
...opts?.short != null ? { short: opts.short } : {},
|
|
169
174
|
...opts?.required != null ? { required: opts.required } : {},
|
|
170
175
|
parse(value) {
|
|
@@ -172,13 +177,14 @@ function boolean(opts) {
|
|
|
172
177
|
}
|
|
173
178
|
};
|
|
174
179
|
}
|
|
175
|
-
|
|
180
|
+
// @__NO_SIDE_EFFECTS__
|
|
176
181
|
function positional(parser) {
|
|
177
182
|
if (parser && "parse" in parser) return {
|
|
178
183
|
type: "positional",
|
|
179
184
|
parse: parser.parse,
|
|
180
185
|
metavar: parser.metavar,
|
|
181
186
|
...parser.description != null ? { description: parser.description } : {},
|
|
187
|
+
...parser.hidden != null ? { hidden: parser.hidden } : {},
|
|
182
188
|
...parser.required != null ? { required: parser.required } : {},
|
|
183
189
|
...parser.default != null ? { default: parser.default } : {}
|
|
184
190
|
};
|
|
@@ -186,6 +192,7 @@ function positional(parser) {
|
|
|
186
192
|
return {
|
|
187
193
|
type: "positional",
|
|
188
194
|
...opts?.description != null ? { description: opts.description } : {},
|
|
195
|
+
...opts?.hidden != null ? { hidden: opts.hidden } : {},
|
|
189
196
|
...opts?.short != null ? { short: opts.short } : {},
|
|
190
197
|
...opts?.required != null ? { required: opts.required } : {}
|
|
191
198
|
};
|
|
@@ -211,13 +218,14 @@ function positional(parser) {
|
|
|
211
218
|
*
|
|
212
219
|
* @experimental
|
|
213
220
|
*/
|
|
214
|
-
|
|
221
|
+
// @__NO_SIDE_EFFECTS__
|
|
215
222
|
function choice(values, opts) {
|
|
216
223
|
return {
|
|
217
224
|
type: "enum",
|
|
218
225
|
metavar: values.join("|"),
|
|
219
226
|
choices: values,
|
|
220
227
|
...opts?.description != null ? { description: opts.description } : {},
|
|
228
|
+
...opts?.hidden != null ? { hidden: opts.hidden } : {},
|
|
221
229
|
...opts?.short != null ? { short: opts.short } : {},
|
|
222
230
|
...opts?.required != null ? { required: opts.required } : {},
|
|
223
231
|
parse(value) {
|
|
@@ -256,12 +264,13 @@ function choice(values, opts) {
|
|
|
256
264
|
*
|
|
257
265
|
* @experimental
|
|
258
266
|
*/
|
|
259
|
-
|
|
267
|
+
// @__NO_SIDE_EFFECTS__
|
|
260
268
|
function combinator(config) {
|
|
261
269
|
return {
|
|
262
270
|
type: "custom",
|
|
263
271
|
metavar: config.metavar ?? "custom",
|
|
264
272
|
...config.description != null ? { description: config.description } : {},
|
|
273
|
+
...config.hidden != null ? { hidden: config.hidden } : {},
|
|
265
274
|
...config.short != null ? { short: config.short } : {},
|
|
266
275
|
...config.required != null ? { required: config.required } : {},
|
|
267
276
|
parse: config.parse
|
|
@@ -289,7 +298,7 @@ function combinator(config) {
|
|
|
289
298
|
*
|
|
290
299
|
* @experimental
|
|
291
300
|
*/
|
|
292
|
-
|
|
301
|
+
// @__NO_SIDE_EFFECTS__
|
|
293
302
|
function map(schema, transform) {
|
|
294
303
|
const baseParse = schema.parse;
|
|
295
304
|
return {
|
|
@@ -319,7 +328,7 @@ function map(schema, transform) {
|
|
|
319
328
|
*
|
|
320
329
|
* @experimental
|
|
321
330
|
*/
|
|
322
|
-
|
|
331
|
+
// @__NO_SIDE_EFFECTS__
|
|
323
332
|
function withDefault(schema, defaultValue) {
|
|
324
333
|
return {
|
|
325
334
|
...schema,
|
|
@@ -345,7 +354,7 @@ function withDefault(schema, defaultValue) {
|
|
|
345
354
|
*
|
|
346
355
|
* @experimental
|
|
347
356
|
*/
|
|
348
|
-
|
|
357
|
+
// @__NO_SIDE_EFFECTS__
|
|
349
358
|
function multiple(schema) {
|
|
350
359
|
return {
|
|
351
360
|
...schema,
|
|
@@ -371,7 +380,7 @@ function multiple(schema) {
|
|
|
371
380
|
*
|
|
372
381
|
* @experimental
|
|
373
382
|
*/
|
|
374
|
-
|
|
383
|
+
// @__NO_SIDE_EFFECTS__
|
|
375
384
|
function required(schema) {
|
|
376
385
|
return {
|
|
377
386
|
...schema,
|
|
@@ -400,7 +409,7 @@ function required(schema) {
|
|
|
400
409
|
*
|
|
401
410
|
* @experimental
|
|
402
411
|
*/
|
|
403
|
-
|
|
412
|
+
// @__NO_SIDE_EFFECTS__
|
|
404
413
|
function short(schema, alias) {
|
|
405
414
|
return {
|
|
406
415
|
...schema,
|
|
@@ -428,7 +437,7 @@ function short(schema, alias) {
|
|
|
428
437
|
*
|
|
429
438
|
* @experimental
|
|
430
439
|
*/
|
|
431
|
-
|
|
440
|
+
// @__NO_SIDE_EFFECTS__
|
|
432
441
|
function describe(schema, text) {
|
|
433
442
|
return {
|
|
434
443
|
...schema,
|
|
@@ -436,6 +445,33 @@ function describe(schema, text) {
|
|
|
436
445
|
};
|
|
437
446
|
}
|
|
438
447
|
/**
|
|
448
|
+
* Hide a combinator schema from generated help or usage output.
|
|
449
|
+
*
|
|
450
|
+
* The original schema is not modified. This only marks renderer metadata and
|
|
451
|
+
* does not change parsing, validation, defaults, conflicts, or resolved values.
|
|
452
|
+
*
|
|
453
|
+
* @typeParam T - The schema type.
|
|
454
|
+
*
|
|
455
|
+
* @param schema - The base combinator schema.
|
|
456
|
+
* @returns A new schema with `hidden: true`.
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```ts
|
|
460
|
+
* const args = {
|
|
461
|
+
* legacy: hidden(string())
|
|
462
|
+
* }
|
|
463
|
+
* ```
|
|
464
|
+
*
|
|
465
|
+
* @experimental
|
|
466
|
+
*/
|
|
467
|
+
// @__NO_SIDE_EFFECTS__
|
|
468
|
+
function hidden(schema) {
|
|
469
|
+
return {
|
|
470
|
+
...schema,
|
|
471
|
+
hidden: true
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
439
475
|
* Mark a combinator schema as not required.
|
|
440
476
|
*
|
|
441
477
|
* Useful for overriding a base combinator that was created with `required: true`,
|
|
@@ -457,7 +493,7 @@ function describe(schema, text) {
|
|
|
457
493
|
*
|
|
458
494
|
* @experimental
|
|
459
495
|
*/
|
|
460
|
-
|
|
496
|
+
// @__NO_SIDE_EFFECTS__
|
|
461
497
|
function unrequired(schema) {
|
|
462
498
|
return {
|
|
463
499
|
...schema,
|
|
@@ -485,11 +521,11 @@ function unrequired(schema) {
|
|
|
485
521
|
*
|
|
486
522
|
* @experimental
|
|
487
523
|
*/
|
|
488
|
-
|
|
524
|
+
// @__NO_SIDE_EFFECTS__
|
|
489
525
|
function args(fields) {
|
|
490
526
|
return fields;
|
|
491
527
|
}
|
|
492
|
-
|
|
528
|
+
// @__NO_SIDE_EFFECTS__
|
|
493
529
|
function merge(...schemas) {
|
|
494
530
|
const result = Object.create(null);
|
|
495
531
|
for (const schema of schemas) for (const key of Object.keys(schema)) result[key] = schema[key];
|
|
@@ -516,7 +552,7 @@ function merge(...schemas) {
|
|
|
516
552
|
*
|
|
517
553
|
* @experimental
|
|
518
554
|
*/
|
|
519
|
-
|
|
555
|
+
// @__NO_SIDE_EFFECTS__
|
|
520
556
|
function extend(base, overrides) {
|
|
521
557
|
const result = Object.create(null);
|
|
522
558
|
for (const key of Object.keys(base)) result[key] = base[key];
|
|
@@ -530,4 +566,4 @@ function extend(base, overrides) {
|
|
|
530
566
|
* @license MIT
|
|
531
567
|
*/
|
|
532
568
|
//#endregion
|
|
533
|
-
export { args, boolean, choice, combinator, describe, extend, float, integer, map, merge, multiple, number, positional, required, short, string, unrequired, withDefault };
|
|
569
|
+
export { args, boolean, choice, combinator, describe, extend, float, hidden, integer, map, merge, multiple, number, positional, required, short, string, unrequired, withDefault };
|
package/lib/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Args, o as ArgToken, r as ArgValues } from "./resolver-
|
|
2
|
-
import { _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, m as DefaultGunshiParams, n as CliOptions, r as Command, s as CommandContextExtension, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, o as ArgToken, r as ArgValues } from "./resolver-mxPNDBm_.js";
|
|
2
|
+
import { _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, m as DefaultGunshiParams, n as CliOptions, r as Command, s as CommandContextExtension, x as LazyCommand, y as GunshiParams } from "./types-DZ0S_FSe.js";
|
|
3
3
|
|
|
4
4
|
//#region src/context.d.ts
|
|
5
5
|
|
package/lib/context.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as CLI_OPTIONS_DEFAULT, r as NOOP, t as ANONYMOUS_COMMAND_NAME } from "./constants-
|
|
2
|
-
import { a as log, i as isLazyCommand, n as deepFreeze, t as create } from "./utils-
|
|
1
|
+
import { n as CLI_OPTIONS_DEFAULT, r as NOOP, t as ANONYMOUS_COMMAND_NAME } from "./constants-CQq1R_68.js";
|
|
2
|
+
import { a as log, i as isLazyCommand, n as deepFreeze, t as create } from "./utils-DNVHO9MQ.js";
|
|
3
3
|
//#region src/context.ts
|
|
4
4
|
/**
|
|
5
5
|
* The entry for gunshi context.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as CLI_OPTIONS_DEFAULT, r as NOOP } from "./constants-
|
|
2
|
-
import { i as isLazyCommand, o as resolveLazyCommand, r as getCommandSubCommands, s as kebabnize, t as create } from "./utils-
|
|
1
|
+
import { n as CLI_OPTIONS_DEFAULT, r as NOOP } from "./constants-CQq1R_68.js";
|
|
2
|
+
import { i as isLazyCommand, o as resolveLazyCommand, r as getCommandSubCommands, s as kebabnize, t as create } from "./utils-DNVHO9MQ.js";
|
|
3
3
|
import { createCommandContext } from "./context.js";
|
|
4
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
4
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.27.0/node_modules/args-tokens/lib/parser.js
|
|
5
5
|
/**
|
|
6
6
|
* forked from `nodejs/node` (`pkgjs/parseargs`)
|
|
7
7
|
* repository url: https://github.com/nodejs/node (https://github.com/pkgjs/parseargs)
|
|
@@ -206,7 +206,7 @@ function hasOptionValue(value) {
|
|
|
206
206
|
return !(value == null) && value.codePointAt(0) !== HYPHEN_CODE;
|
|
207
207
|
}
|
|
208
208
|
//#endregion
|
|
209
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
209
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.27.0/node_modules/args-tokens/lib/resolver.js
|
|
210
210
|
/**
|
|
211
211
|
* Entry point of argument options resolver.
|
|
212
212
|
*
|
|
@@ -368,37 +368,53 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
368
368
|
explicit[rawArg] = false;
|
|
369
369
|
if (schema.type === "positional") {
|
|
370
370
|
if (skipPositionalIndex > SKIP_POSITIONAL_DEFAULT) while (positionalsCount <= getPositionalSkipIndex()) positionalsCount++;
|
|
371
|
-
const requiredPositionals = getRequiredPositionalsAfter(rawArg);
|
|
372
|
-
const availablePositionals = Math.max(positionalTokens.length - positionalsCount, 0);
|
|
373
371
|
if (schema.multiple) {
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
372
|
+
const availablePositionals = Math.max(positionalTokens.length - positionalsCount, 0);
|
|
373
|
+
if (availablePositionals > 0) {
|
|
374
|
+
const requiredPositionals = getRequiredPositionalsAfter(rawArg);
|
|
375
|
+
const positionalsToConsume = Math.max(availablePositionals - requiredPositionals, 0);
|
|
376
|
+
if (positionalsToConsume > 0) {
|
|
377
|
+
const endPositionals = positionalsCount + positionalsToConsume;
|
|
378
|
+
if (typeof schema.parse === "function") {
|
|
379
|
+
const parsed = [];
|
|
380
|
+
for (let i = positionalsCount; i < endPositionals; i++) {
|
|
381
|
+
const p = positionalTokens[i];
|
|
382
|
+
try {
|
|
383
|
+
parsed.push(schema.parse(p.value));
|
|
384
|
+
} catch (error) {
|
|
385
|
+
errors.push(error);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
values[rawArg] = parsed;
|
|
389
|
+
} else {
|
|
390
|
+
const valuesArray = [];
|
|
391
|
+
for (let i = positionalsCount; i < endPositionals; i++) valuesArray.push(positionalTokens[i].value);
|
|
392
|
+
values[rawArg] = valuesArray;
|
|
383
393
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
explicit[rawArg] = true;
|
|
394
|
+
positionalsCount = endPositionals;
|
|
395
|
+
explicit[rawArg] = true;
|
|
396
|
+
} else if (schema.required) errors.push(createRequireError(arg, schema));
|
|
388
397
|
} else if (schema.required) errors.push(createRequireError(arg, schema));
|
|
389
398
|
} else {
|
|
390
399
|
const positional = positionalTokens[positionalsCount];
|
|
391
|
-
if (
|
|
392
|
-
if (
|
|
393
|
-
values
|
|
394
|
-
|
|
395
|
-
|
|
400
|
+
if (shouldRequireMissingSinglePositional(schema)) {
|
|
401
|
+
if (positional != null) {
|
|
402
|
+
resolveSinglePositionalValue(values, errors, rawArg, schema, positional);
|
|
403
|
+
explicit[rawArg] = true;
|
|
404
|
+
positionalsCount++;
|
|
405
|
+
} else errors.push(createRequireError(arg, schema));
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
if (positional != null) {
|
|
409
|
+
const requiredPositionals = getRequiredPositionalsAfter(rawArg);
|
|
410
|
+
if (Math.max(positionalTokens.length - positionalsCount, 0) > requiredPositionals) {
|
|
411
|
+
resolveSinglePositionalValue(values, errors, rawArg, schema, positional);
|
|
412
|
+
explicit[rawArg] = true;
|
|
413
|
+
positionalsCount++;
|
|
414
|
+
continue;
|
|
396
415
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
positionalsCount++;
|
|
400
|
-
} else if (shouldRequireMissingSinglePositional(schema)) errors.push(createRequireError(arg, schema));
|
|
401
|
-
else if (hasDefault(schema)) values[rawArg] = schema.default;
|
|
416
|
+
}
|
|
417
|
+
if (hasDefault(schema)) values[rawArg] = schema.default;
|
|
402
418
|
}
|
|
403
419
|
continue;
|
|
404
420
|
}
|
|
@@ -467,6 +483,14 @@ function parse(token, option, schema) {
|
|
|
467
483
|
function createRequireError(option, schema) {
|
|
468
484
|
return new ArgResolveError(schema.type === "positional" ? `Positional argument '${option}' is required` : `Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}is required`, option, "required", schema);
|
|
469
485
|
}
|
|
486
|
+
function resolveSinglePositionalValue(values, errors, rawArg, schema, positional) {
|
|
487
|
+
if (typeof schema.parse === "function") try {
|
|
488
|
+
values[rawArg] = schema.parse(positional.value);
|
|
489
|
+
} catch (error) {
|
|
490
|
+
errors.push(error);
|
|
491
|
+
}
|
|
492
|
+
else values[rawArg] = positional.value;
|
|
493
|
+
}
|
|
470
494
|
function hasDefault(schema) {
|
|
471
495
|
return schema.default != null;
|
|
472
496
|
}
|
|
@@ -540,7 +564,7 @@ function checkConflicts(args, explicit, toKebab, actualInputNames) {
|
|
|
540
564
|
return [];
|
|
541
565
|
}
|
|
542
566
|
//#endregion
|
|
543
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
567
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.27.0/node_modules/args-tokens/lib/index.js
|
|
544
568
|
/**
|
|
545
569
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
546
570
|
* @license MIT
|
package/lib/definition.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema, r as ArgValues } from "./resolver-
|
|
2
|
-
import { C as NormalizeToGunshiParams, _ as ExtractArgs, b as GunshiParamsConstraint, d as CommandLoader, f as CommandRunner, h as ExtendContext, m as DefaultGunshiParams, r as Command, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, n as ArgSchema, r as ArgValues } from "./resolver-mxPNDBm_.js";
|
|
2
|
+
import { C as NormalizeToGunshiParams, _ as ExtractArgs, b as GunshiParamsConstraint, d as CommandLoader, f as CommandRunner, h as ExtendContext, m as DefaultGunshiParams, r as Command, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-DZ0S_FSe.js";
|
|
3
3
|
import { CommandContextParams, createCommandContext } from "./context.js";
|
|
4
4
|
|
|
5
5
|
//#region src/definition.d.ts
|
|
@@ -77,7 +77,7 @@ type DefineWithTypesReturn<DefaultExtensions extends ExtendContext, DefaultArgs
|
|
|
77
77
|
/**
|
|
78
78
|
* Define a {@link Command | command} with types
|
|
79
79
|
*
|
|
80
|
-
* This helper function allows specifying the type parameter of {@link
|
|
80
|
+
* This helper function allows specifying the type parameter of {@link GunshiParamsConstraint}
|
|
81
81
|
* while inferring the {@link Args} type, {@link ExtendContext} type from the definition.
|
|
82
82
|
*
|
|
83
83
|
* @example
|
|
@@ -97,7 +97,7 @@ type DefineWithTypesReturn<DefaultExtensions extends ExtendContext, DefaultArgs
|
|
|
97
97
|
* })
|
|
98
98
|
* ```
|
|
99
99
|
*
|
|
100
|
-
* @typeParam G - A {@link
|
|
100
|
+
* @typeParam G - A {@link GunshiParamsConstraint} type
|
|
101
101
|
*
|
|
102
102
|
* @returns A function that takes a command definition via {@link define}
|
|
103
103
|
*
|
|
@@ -153,30 +153,39 @@ declare function lazy<A extends Args>(loader: CommandLoader<{
|
|
|
153
153
|
* }, testDefinition)
|
|
154
154
|
* ```
|
|
155
155
|
*
|
|
156
|
-
* @typeParam
|
|
157
|
-
* @typeParam D - A partial {@link Command} definition type
|
|
156
|
+
* @typeParam D - A partial {@link Command} definition type with required `args`
|
|
158
157
|
*
|
|
159
158
|
* @param loader - A {@link CommandLoader | command loader} function that returns a command definition
|
|
160
|
-
* @param definition -
|
|
159
|
+
* @param definition - A {@link Command | command} definition
|
|
161
160
|
* @returns A {@link LazyCommand | lazy command} that can be executed later
|
|
162
161
|
*/
|
|
163
|
-
declare function lazy<
|
|
164
|
-
args:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
args: A;
|
|
162
|
+
declare function lazy<D extends {
|
|
163
|
+
args: Args;
|
|
164
|
+
} & Partial<Command<{
|
|
165
|
+
args: D['args'];
|
|
168
166
|
extensions: {};
|
|
169
167
|
}>>>(loader: CommandLoader<{
|
|
170
|
-
args:
|
|
168
|
+
args: D['args'];
|
|
171
169
|
extensions: {};
|
|
172
170
|
}>, definition: D): LazyCommand<{
|
|
173
|
-
args:
|
|
171
|
+
args: D['args'];
|
|
174
172
|
extensions: {};
|
|
175
173
|
}, D>;
|
|
174
|
+
/**
|
|
175
|
+
* Define a {@link LazyCommand | lazy command} with explicit Gunshi parameters and optional definition.
|
|
176
|
+
*
|
|
177
|
+
* @typeParam G - A {@link GunshiParamsConstraint}
|
|
178
|
+
* @typeParam D - A partial {@link Command} definition type
|
|
179
|
+
*
|
|
180
|
+
* @param loader - A {@link CommandLoader | command loader} function that returns a command definition
|
|
181
|
+
* @param definition - An optional {@link Command | command} definition
|
|
182
|
+
* @returns A {@link LazyCommand | lazy command} that can be executed later
|
|
183
|
+
*/
|
|
184
|
+
declare function lazy<G extends GunshiParamsConstraint = DefaultGunshiParams, D extends Partial<Command<G>> = Partial<Command<G>>>(loader: CommandLoader<G>, definition?: D): LazyCommand<G, D>;
|
|
176
185
|
/**
|
|
177
186
|
* Return type for lazyWithTypes
|
|
178
187
|
*
|
|
179
|
-
* @typeParam FullG - The normalized {@link
|
|
188
|
+
* @typeParam FullG - The normalized {@link GunshiParamsConstraint} type
|
|
180
189
|
*
|
|
181
190
|
* @internal
|
|
182
191
|
*/
|
|
@@ -184,7 +193,7 @@ type LazyWithTypesReturn<FullG extends GunshiParamsConstraint> = <D extends Part
|
|
|
184
193
|
/**
|
|
185
194
|
* Define a {@link LazyCommand | lazy command} with specific type parameters.
|
|
186
195
|
*
|
|
187
|
-
* This helper function allows specifying the type parameter of {@link
|
|
196
|
+
* This helper function allows specifying the type parameter of {@link GunshiParamsConstraint}
|
|
188
197
|
* while inferring the {@link Args} type, {@link ExtendContext} type from the definition.
|
|
189
198
|
*
|
|
190
199
|
* @example
|
|
@@ -209,7 +218,7 @@ type LazyWithTypesReturn<FullG extends GunshiParamsConstraint> = <D extends Part
|
|
|
209
218
|
* )
|
|
210
219
|
* ```
|
|
211
220
|
*
|
|
212
|
-
* @typeParam G - A {@link
|
|
221
|
+
* @typeParam G - A {@link GunshiParamsConstraint} type
|
|
213
222
|
*
|
|
214
223
|
* @returns A function that takes a lazy command definition via {@link lazy}
|
|
215
224
|
*
|
package/lib/definition.js
CHANGED
|
@@ -18,7 +18,7 @@ function define(definition) {
|
|
|
18
18
|
/**
|
|
19
19
|
* Define a {@link Command | command} with types
|
|
20
20
|
*
|
|
21
|
-
* This helper function allows specifying the type parameter of {@link
|
|
21
|
+
* This helper function allows specifying the type parameter of {@link GunshiParamsConstraint}
|
|
22
22
|
* while inferring the {@link Args} type, {@link ExtendContext} type from the definition.
|
|
23
23
|
*
|
|
24
24
|
* @example
|
|
@@ -38,7 +38,7 @@ function define(definition) {
|
|
|
38
38
|
* })
|
|
39
39
|
* ```
|
|
40
40
|
*
|
|
41
|
-
* @typeParam G - A {@link
|
|
41
|
+
* @typeParam G - A {@link GunshiParamsConstraint} type
|
|
42
42
|
*
|
|
43
43
|
* @returns A function that takes a command definition via {@link define}
|
|
44
44
|
*
|
|
@@ -74,7 +74,7 @@ function lazy(loader, definition) {
|
|
|
74
74
|
/**
|
|
75
75
|
* Define a {@link LazyCommand | lazy command} with specific type parameters.
|
|
76
76
|
*
|
|
77
|
-
* This helper function allows specifying the type parameter of {@link
|
|
77
|
+
* This helper function allows specifying the type parameter of {@link GunshiParamsConstraint}
|
|
78
78
|
* while inferring the {@link Args} type, {@link ExtendContext} type from the definition.
|
|
79
79
|
*
|
|
80
80
|
* @example
|
|
@@ -99,7 +99,7 @@ function lazy(loader, definition) {
|
|
|
99
99
|
* )
|
|
100
100
|
* ```
|
|
101
101
|
*
|
|
102
|
-
* @typeParam G - A {@link
|
|
102
|
+
* @typeParam G - A {@link GunshiParamsConstraint} type
|
|
103
103
|
*
|
|
104
104
|
* @returns A function that takes a lazy command definition via {@link lazy}
|
|
105
105
|
*
|
package/lib/generator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, n as CliOptions, r as Command, x as LazyCommand } from "./types-
|
|
1
|
+
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, n as CliOptions, r as Command, x as LazyCommand } from "./types-DZ0S_FSe.js";
|
|
2
2
|
|
|
3
3
|
//#region src/generator.d.ts
|
|
4
4
|
|
package/lib/generator.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as create } from "./utils-
|
|
2
|
-
import { t as cli } from "./cli-
|
|
1
|
+
import { t as create } from "./utils-DNVHO9MQ.js";
|
|
2
|
+
import { t as cli } from "./cli-DoX4INTi.js";
|
|
3
3
|
//#region src/generator.ts
|
|
4
4
|
/**
|
|
5
5
|
* The entry for usage generator.
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as resolveArgs, i as Args, n as ArgSchema, o as ArgToken, r as ArgValues, s as parseArgs } from "./resolver-
|
|
2
|
-
import { A as Plugin, C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, F as PluginWithExtension, I as PluginWithoutExtension, L as plugin, M as PluginExtension, N as PluginFunction, O as ValidationErrorsDecorator, P as PluginOptions, R as PluginContext, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, j as PluginDependency, k as OnPluginExtension, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { a as resolveArgs, i as Args, n as ArgSchema, o as ArgToken, r as ArgValues, s as parseArgs } from "./resolver-mxPNDBm_.js";
|
|
2
|
+
import { A as Plugin, C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, F as PluginWithExtension, I as PluginWithoutExtension, L as plugin, M as PluginExtension, N as PluginFunction, O as ValidationErrorsDecorator, P as PluginOptions, R as PluginContext, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, j as PluginDependency, k as OnPluginExtension, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-DZ0S_FSe.js";
|
|
3
3
|
import { CommandContextParams, createCommandContext } from "./context.js";
|
|
4
4
|
import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition.js";
|
|
5
|
-
import { t as ANONYMOUS_COMMAND_NAME } from "./constants-
|
|
5
|
+
import { t as ANONYMOUS_COMMAND_NAME } from "./constants-BkgP86Yw.js";
|
|
6
6
|
|
|
7
7
|
//#region ../plugin-i18n/src/types.d.ts
|
|
8
8
|
/**
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as ANONYMOUS_COMMAND_NAME } from "./constants-
|
|
1
|
+
import { t as ANONYMOUS_COMMAND_NAME } from "./constants-CQq1R_68.js";
|
|
2
2
|
import { createCommandContext } from "./context.js";
|
|
3
|
-
import { t as plugin } from "./core-
|
|
4
|
-
import { a as namespacedId } from "./src-
|
|
5
|
-
import { n as resolveArgs, r as parseArgs } from "./core-
|
|
6
|
-
import { t as cli } from "./cli-
|
|
3
|
+
import { t as plugin } from "./core-CFEvRYOJ.js";
|
|
4
|
+
import { a as namespacedId } from "./src-B4uHG_qb.js";
|
|
5
|
+
import { n as resolveArgs, r as parseArgs } from "./core-xgWIcbHL.js";
|
|
6
|
+
import { t as cli } from "./cli-DoX4INTi.js";
|
|
7
7
|
import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition.js";
|
|
8
8
|
//#region ../plugin-i18n/src/translation.ts
|
|
9
9
|
/**
|
package/lib/plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues } from "./resolver-
|
|
2
|
-
import { A as Plugin, C as NormalizeToGunshiParams, F as PluginWithExtension, I as PluginWithoutExtension, L as plugin, M as PluginExtension, N as PluginFunction, O as ValidationErrorsDecorator, P as PluginOptions, R as PluginContext, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, f as CommandRunner, h as ExtendContext, j as PluginDependency, k as OnPluginExtension, m as DefaultGunshiParams, o as CommandContextCore, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues } from "./resolver-mxPNDBm_.js";
|
|
2
|
+
import { A as Plugin, C as NormalizeToGunshiParams, F as PluginWithExtension, I as PluginWithoutExtension, L as plugin, M as PluginExtension, N as PluginFunction, O as ValidationErrorsDecorator, P as PluginOptions, R as PluginContext, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, f as CommandRunner, h as ExtendContext, j as PluginDependency, k as OnPluginExtension, m as DefaultGunshiParams, o as CommandContextCore, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-DZ0S_FSe.js";
|
|
3
3
|
import { CommandContextParams, createCommandContext } from "./context.js";
|
|
4
|
-
import { n as CLI_OPTIONS_DEFAULT, t as ANONYMOUS_COMMAND_NAME } from "./constants-
|
|
4
|
+
import { n as CLI_OPTIONS_DEFAULT, t as ANONYMOUS_COMMAND_NAME } from "./constants-BkgP86Yw.js";
|
|
5
5
|
|
|
6
6
|
//#region src/plugin.d.ts
|
|
7
7
|
/**
|
package/lib/plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as CLI_OPTIONS_DEFAULT, t as ANONYMOUS_COMMAND_NAME } from "./constants-
|
|
1
|
+
import { n as CLI_OPTIONS_DEFAULT, t as ANONYMOUS_COMMAND_NAME } from "./constants-CQq1R_68.js";
|
|
2
2
|
import { createCommandContext } from "./context.js";
|
|
3
|
-
import { t as plugin } from "./core-
|
|
3
|
+
import { t as plugin } from "./core-CFEvRYOJ.js";
|
|
4
4
|
//#region src/plugin.ts
|
|
5
5
|
/**
|
|
6
6
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
package/lib/renderer.d.ts
CHANGED
package/lib/renderer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as renderHeader, n as renderValidationErrors, r as renderUsage } from "./src-
|
|
1
|
+
import { i as renderHeader, n as renderValidationErrors, r as renderUsage } from "./src-B4uHG_qb.js";
|
|
2
2
|
//#region src/renderer.ts
|
|
3
3
|
/**
|
|
4
4
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
@@ -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.
|
|
@@ -88,13 +88,13 @@ declare function parseArgs(args: string[], options?: ParserOptions): ArgToken[];
|
|
|
88
88
|
* @returns Whether `arg` is a short option.
|
|
89
89
|
*/
|
|
90
90
|
//#endregion
|
|
91
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
91
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.27.0/node_modules/args-tokens/lib/resolver.d.ts
|
|
92
92
|
//#region src/resolver.d.ts
|
|
93
93
|
/**
|
|
94
94
|
* An argument schema definition for command-line argument parsing.
|
|
95
95
|
*
|
|
96
96
|
* This schema is similar to the schema of Node.js `util.parseArgs` but with extended features:
|
|
97
|
-
* - Additional `required` and `
|
|
97
|
+
* - Additional `required`, `description`, and `hidden` properties
|
|
98
98
|
* - Extended `type` support: 'string', 'boolean', 'number', 'enum', 'positional', 'custom'
|
|
99
99
|
* - Simplified `default` property (single type, not union types)
|
|
100
100
|
*
|
|
@@ -199,6 +199,25 @@ interface ArgSchema {
|
|
|
199
199
|
* ```
|
|
200
200
|
*/
|
|
201
201
|
description?: string;
|
|
202
|
+
/**
|
|
203
|
+
* Hide the argument from generated help or usage output.
|
|
204
|
+
*
|
|
205
|
+
* This is metadata for renderers. It does not affect parsing, validation,
|
|
206
|
+
* required checks, defaults, conflicts, or resolved values.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* Hidden compatibility option:
|
|
210
|
+
* ```ts
|
|
211
|
+
* {
|
|
212
|
+
* legacy: {
|
|
213
|
+
* type: 'string',
|
|
214
|
+
* hidden: true,
|
|
215
|
+
* description: 'Deprecated compatibility option'
|
|
216
|
+
* }
|
|
217
|
+
* }
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
hidden?: boolean;
|
|
202
221
|
/**
|
|
203
222
|
* Marks the argument as required.
|
|
204
223
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./constants-
|
|
2
|
-
import { o as resolveLazyCommand, s as kebabnize } from "./utils-
|
|
3
|
-
import { t as plugin } from "./core-
|
|
1
|
+
import "./constants-CQq1R_68.js";
|
|
2
|
+
import { o as resolveLazyCommand, s as kebabnize } from "./utils-DNVHO9MQ.js";
|
|
3
|
+
import { t as plugin } from "./core-CFEvRYOJ.js";
|
|
4
4
|
/**
|
|
5
5
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
6
6
|
* @license MIT
|
|
@@ -202,6 +202,15 @@ const pluginId = namespacedId("renderer");
|
|
|
202
202
|
* @license MIT
|
|
203
203
|
*/
|
|
204
204
|
const COMMON_ARGS_KEYS = Object.keys(COMMON_ARGS);
|
|
205
|
+
function isHiddenArg(schema) {
|
|
206
|
+
return schema.hidden === true;
|
|
207
|
+
}
|
|
208
|
+
function getVisibleOptionalArgs(args) {
|
|
209
|
+
return Object.entries(args).filter(([_, schema]) => schema.type !== "positional" && !isHiddenArg(schema));
|
|
210
|
+
}
|
|
211
|
+
function getVisiblePositionalArgs(args) {
|
|
212
|
+
return Object.entries(args).filter(([_, schema]) => schema.type === "positional" && !isHiddenArg(schema));
|
|
213
|
+
}
|
|
205
214
|
/**
|
|
206
215
|
* Render the usage.
|
|
207
216
|
*
|
|
@@ -383,7 +392,7 @@ async function hasCommands(ctx) {
|
|
|
383
392
|
* @returns True if the command has options
|
|
384
393
|
*/
|
|
385
394
|
function hasOptionalArgs(args) {
|
|
386
|
-
return
|
|
395
|
+
return getVisibleOptionalArgs(args).length > 0;
|
|
387
396
|
}
|
|
388
397
|
/**
|
|
389
398
|
* Check if the command has positional arguments
|
|
@@ -392,7 +401,7 @@ function hasOptionalArgs(args) {
|
|
|
392
401
|
* @returns True if the command has options
|
|
393
402
|
*/
|
|
394
403
|
function hasPositionalArgs(args) {
|
|
395
|
-
return
|
|
404
|
+
return getVisiblePositionalArgs(args).length > 0;
|
|
396
405
|
}
|
|
397
406
|
/**
|
|
398
407
|
* Check if all options have default values
|
|
@@ -401,7 +410,8 @@ function hasPositionalArgs(args) {
|
|
|
401
410
|
* @returns True if all options have default values
|
|
402
411
|
*/
|
|
403
412
|
function hasAllDefaultOptions(args) {
|
|
404
|
-
|
|
413
|
+
const visibleOptionalArgs = getVisibleOptionalArgs(args);
|
|
414
|
+
return visibleOptionalArgs.length > 0 && visibleOptionalArgs.every(([_, arg]) => arg.default);
|
|
405
415
|
}
|
|
406
416
|
/**
|
|
407
417
|
* Generate options symbols for usage
|
|
@@ -411,7 +421,7 @@ function hasAllDefaultOptions(args) {
|
|
|
411
421
|
* @returns Options symbols for usage
|
|
412
422
|
*/
|
|
413
423
|
async function generateOptionsSymbols(ctx, args) {
|
|
414
|
-
return
|
|
424
|
+
return getVisibleOptionalArgs(args).length > 0 ? hasAllDefaultOptions(args) ? `[${await ctx.extensions[pluginId].text(resolveBuiltInKey("OPTIONS"))}]` : `<${await ctx.extensions[pluginId].text(resolveBuiltInKey("OPTIONS"))}>` : "";
|
|
415
425
|
}
|
|
416
426
|
/**
|
|
417
427
|
* Get optional arguments pairs for usage
|
|
@@ -420,8 +430,7 @@ async function generateOptionsSymbols(ctx, args) {
|
|
|
420
430
|
* @returns Options pairs for usage
|
|
421
431
|
*/
|
|
422
432
|
function getOptionalArgsPairs(ctx) {
|
|
423
|
-
return
|
|
424
|
-
if (schema.type === "positional") return acc;
|
|
433
|
+
return getVisibleOptionalArgs(ctx.args).reduce((acc, [name, schema]) => {
|
|
425
434
|
let key = makeShortLongOptionPair(schema, name, ctx.toKebab);
|
|
426
435
|
if (schema.type !== "boolean") {
|
|
427
436
|
const displayName = ctx.toKebab || schema.toKebab ? kebabnize(name) : name;
|
|
@@ -461,9 +470,11 @@ async function resolveDisplayValue(ctx, key) {
|
|
|
461
470
|
* @returns Generated options usage
|
|
462
471
|
*/
|
|
463
472
|
async function generateOptionalArgsUsage(ctx, optionsPairs) {
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
473
|
+
const optionsPairsEntries = Object.entries(optionsPairs);
|
|
474
|
+
if (optionsPairsEntries.length === 0) return "";
|
|
475
|
+
const optionsMaxLength = Math.max(...optionsPairsEntries.map(([_, value]) => value.length));
|
|
476
|
+
const optionSchemaMaxLength = ctx.env.usageOptionType ? Math.max(...optionsPairsEntries.map(([key]) => resolveNegatableType(key, ctx).length)) : 0;
|
|
477
|
+
return (await Promise.all(optionsPairsEntries.map(async ([key, value]) => {
|
|
467
478
|
let rawDesc = await ctx.extensions[pluginId].text(resolveArgKey(key, ctx.name));
|
|
468
479
|
if (!rawDesc && key.startsWith("no-")) {
|
|
469
480
|
const name = resolveNegatableKey(key);
|
|
@@ -480,10 +491,11 @@ async function generateOptionalArgsUsage(ctx, optionsPairs) {
|
|
|
480
491
|
}))).join("\n");
|
|
481
492
|
}
|
|
482
493
|
function getPositionalArgs(args) {
|
|
483
|
-
return
|
|
494
|
+
return getVisiblePositionalArgs(args);
|
|
484
495
|
}
|
|
485
496
|
async function generatePositionalArgsUsage(ctx) {
|
|
486
497
|
const positionals = getPositionalArgs(ctx.args);
|
|
498
|
+
if (positionals.length === 0) return "";
|
|
487
499
|
const argsMaxLength = Math.max(...positionals.map(([name]) => name.length));
|
|
488
500
|
return (await Promise.all(positionals.map(async ([name]) => {
|
|
489
501
|
const desc = await ctx.extensions[pluginId].text(resolveArgKey(name, ctx.name)) || ctx.args[name].description || "";
|
|
@@ -492,7 +504,8 @@ async function generatePositionalArgsUsage(ctx) {
|
|
|
492
504
|
}))).join("\n");
|
|
493
505
|
}
|
|
494
506
|
function generatePositionalSymbols(args) {
|
|
495
|
-
|
|
507
|
+
const visiblePositionalArgs = getVisiblePositionalArgs(args);
|
|
508
|
+
return visiblePositionalArgs.length > 0 ? visiblePositionalArgs.map(([name, arg]) => {
|
|
496
509
|
const elements = [];
|
|
497
510
|
if (arg.multiple) {
|
|
498
511
|
if (arg.required) elements.push(`<${name}>`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues, t as ArgExplicitlyProvided } from "./resolver-
|
|
1
|
+
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues, t as ArgExplicitlyProvided } from "./resolver-mxPNDBm_.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin/context.d.ts
|
|
4
4
|
/**
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, p as Commandable, r as Command, x as LazyCommand } from "./types-
|
|
1
|
+
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, p as Commandable, r as Command, x as LazyCommand } from "./types-DZ0S_FSe.js";
|
|
2
2
|
|
|
3
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
3
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.27.0/node_modules/args-tokens/lib/utils.d.ts
|
|
4
4
|
|
|
5
5
|
//#region src/utils.d.ts
|
|
6
6
|
/**
|
package/lib/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as log, i as isLazyCommand, n as deepFreeze, o as resolveLazyCommand, r as getCommandSubCommands, s as kebabnize, t as create } from "./utils-
|
|
1
|
+
import { a as log, i as isLazyCommand, n as deepFreeze, o as resolveLazyCommand, r as getCommandSubCommands, s as kebabnize, t as create } from "./utils-DNVHO9MQ.js";
|
|
2
2
|
export { create, deepFreeze, getCommandSubCommands, isLazyCommand, kebabnize, log, resolveLazyCommand };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gunshi",
|
|
3
3
|
"description": "Modern javascript command-line library",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.35.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"args-tokens": "^0.
|
|
111
|
+
"args-tokens": "^0.27.0",
|
|
112
112
|
"deno": "^2.7.14",
|
|
113
113
|
"jsr": "^0.14.3",
|
|
114
114
|
"jsr-exports-lint": "^0.4.2",
|
|
@@ -116,11 +116,11 @@
|
|
|
116
116
|
"std-env": "^4.1.0",
|
|
117
117
|
"tsdown": "0.21.0",
|
|
118
118
|
"zod": "^4.4.3",
|
|
119
|
-
"@gunshi/plugin-
|
|
120
|
-
"@gunshi/plugin-
|
|
121
|
-
"@gunshi/
|
|
122
|
-
"@gunshi/
|
|
123
|
-
"@gunshi/
|
|
119
|
+
"@gunshi/plugin-i18n": "0.35.0",
|
|
120
|
+
"@gunshi/plugin-global": "0.35.0",
|
|
121
|
+
"@gunshi/plugin-renderer": "0.35.0",
|
|
122
|
+
"@gunshi/resources": "0.35.0",
|
|
123
|
+
"@gunshi/shared": "0.35.0"
|
|
124
124
|
},
|
|
125
125
|
"scripts": {
|
|
126
126
|
"build": "tsdown",
|
|
File without changes
|
|
File without changes
|