gunshi 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/bone.d.ts +2 -2
- package/lib/bone.js +1 -1
- package/lib/{cli-DfaFk6tk.js → cli-DoX4INTi.js} +3 -3
- package/lib/combinators.d.ts +42 -7
- package/lib/combinators.js +63 -24
- package/lib/{constants-XndHBbIz.d.ts → constants-BkgP86Yw.d.ts} +1 -1
- package/lib/context.d.ts +2 -2
- package/lib/context.js +2 -2
- package/lib/{core-BKtZQ6dG.js → core-xgWIcbHL.js} +84 -26
- 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-CIPNDx1a.d.ts → resolver-mxPNDBm_.d.ts} +35 -7
- package/lib/{src-dTYUlEw_.js → src-B4uHG_qb.js} +36 -16
- package/lib/{types-CUdYQC8F.d.ts → types-DZ0S_FSe.d.ts} +1 -1
- package/lib/{utils-jNy8sqR5.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
|
*/
|
|
@@ -242,6 +246,7 @@ type ArgSchemaPositionalType = {
|
|
|
242
246
|
* const args = {
|
|
243
247
|
* command: positional(), // resolves to string
|
|
244
248
|
* port: positional(integer()), // resolves to number
|
|
249
|
+
* query: unrequired(positional()) // optional positional
|
|
245
250
|
* }
|
|
246
251
|
* ```
|
|
247
252
|
*
|
|
@@ -262,6 +267,7 @@ declare function positional<T>(parser: CombinatorSchema<T>): CombinatorSchema<T>
|
|
|
262
267
|
* const args = {
|
|
263
268
|
* command: positional(), // resolves to string
|
|
264
269
|
* port: positional(integer()), // resolves to number
|
|
270
|
+
* query: unrequired(positional()) // optional positional
|
|
265
271
|
* }
|
|
266
272
|
* ```
|
|
267
273
|
*
|
|
@@ -502,6 +508,33 @@ type CombinatorDescribe<D extends string> = {
|
|
|
502
508
|
* @experimental
|
|
503
509
|
*/
|
|
504
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;
|
|
505
538
|
/**
|
|
506
539
|
* Options for the {@link unrequired} combinator.
|
|
507
540
|
*/
|
|
@@ -511,10 +544,11 @@ type CombinatorUnrequired = {
|
|
|
511
544
|
/**
|
|
512
545
|
* Mark a combinator schema as not required.
|
|
513
546
|
*
|
|
514
|
-
* Useful for overriding a base combinator that was created with `required: true
|
|
547
|
+
* Useful for overriding a base combinator that was created with `required: true`,
|
|
548
|
+
* or for making a positional argument explicitly optional.
|
|
515
549
|
* The original schema is not modified.
|
|
516
550
|
*
|
|
517
|
-
* @typeParam T - The schema
|
|
551
|
+
* @typeParam T - The schema type.
|
|
518
552
|
*
|
|
519
553
|
* @param schema - The base combinator schema.
|
|
520
554
|
* @returns A new schema with `required: false`.
|
|
@@ -522,13 +556,14 @@ type CombinatorUnrequired = {
|
|
|
522
556
|
* @example
|
|
523
557
|
* ```ts
|
|
524
558
|
* const args = {
|
|
525
|
-
* name: unrequired(string({ required: true }))
|
|
559
|
+
* name: unrequired(string({ required: true })),
|
|
560
|
+
* query: unrequired(positional())
|
|
526
561
|
* }
|
|
527
562
|
* ```
|
|
528
563
|
*
|
|
529
564
|
* @experimental
|
|
530
565
|
*/
|
|
531
|
-
declare function unrequired<T>(schema:
|
|
566
|
+
declare function unrequired<T extends ArgSchema>(schema: T): Omit<T, 'required'> & CombinatorUnrequired;
|
|
532
567
|
/**
|
|
533
568
|
* Recursively merge a tuple of {@link Args} types.
|
|
534
569
|
* Later types override earlier ones on key conflicts.
|
|
@@ -643,4 +678,4 @@ declare function extend<T extends Args, U extends Args>(base: T, overrides: U):
|
|
|
643
678
|
*/
|
|
644
679
|
|
|
645
680
|
//#endregion
|
|
646
|
-
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,19 +177,22 @@ 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 } : {},
|
|
182
|
-
...parser.
|
|
187
|
+
...parser.hidden != null ? { hidden: parser.hidden } : {},
|
|
188
|
+
...parser.required != null ? { required: parser.required } : {},
|
|
189
|
+
...parser.default != null ? { default: parser.default } : {}
|
|
183
190
|
};
|
|
184
191
|
const opts = parser;
|
|
185
192
|
return {
|
|
186
193
|
type: "positional",
|
|
187
194
|
...opts?.description != null ? { description: opts.description } : {},
|
|
195
|
+
...opts?.hidden != null ? { hidden: opts.hidden } : {},
|
|
188
196
|
...opts?.short != null ? { short: opts.short } : {},
|
|
189
197
|
...opts?.required != null ? { required: opts.required } : {}
|
|
190
198
|
};
|
|
@@ -210,13 +218,14 @@ function positional(parser) {
|
|
|
210
218
|
*
|
|
211
219
|
* @experimental
|
|
212
220
|
*/
|
|
213
|
-
|
|
221
|
+
// @__NO_SIDE_EFFECTS__
|
|
214
222
|
function choice(values, opts) {
|
|
215
223
|
return {
|
|
216
224
|
type: "enum",
|
|
217
225
|
metavar: values.join("|"),
|
|
218
226
|
choices: values,
|
|
219
227
|
...opts?.description != null ? { description: opts.description } : {},
|
|
228
|
+
...opts?.hidden != null ? { hidden: opts.hidden } : {},
|
|
220
229
|
...opts?.short != null ? { short: opts.short } : {},
|
|
221
230
|
...opts?.required != null ? { required: opts.required } : {},
|
|
222
231
|
parse(value) {
|
|
@@ -255,12 +264,13 @@ function choice(values, opts) {
|
|
|
255
264
|
*
|
|
256
265
|
* @experimental
|
|
257
266
|
*/
|
|
258
|
-
|
|
267
|
+
// @__NO_SIDE_EFFECTS__
|
|
259
268
|
function combinator(config) {
|
|
260
269
|
return {
|
|
261
270
|
type: "custom",
|
|
262
271
|
metavar: config.metavar ?? "custom",
|
|
263
272
|
...config.description != null ? { description: config.description } : {},
|
|
273
|
+
...config.hidden != null ? { hidden: config.hidden } : {},
|
|
264
274
|
...config.short != null ? { short: config.short } : {},
|
|
265
275
|
...config.required != null ? { required: config.required } : {},
|
|
266
276
|
parse: config.parse
|
|
@@ -288,7 +298,7 @@ function combinator(config) {
|
|
|
288
298
|
*
|
|
289
299
|
* @experimental
|
|
290
300
|
*/
|
|
291
|
-
|
|
301
|
+
// @__NO_SIDE_EFFECTS__
|
|
292
302
|
function map(schema, transform) {
|
|
293
303
|
const baseParse = schema.parse;
|
|
294
304
|
return {
|
|
@@ -318,7 +328,7 @@ function map(schema, transform) {
|
|
|
318
328
|
*
|
|
319
329
|
* @experimental
|
|
320
330
|
*/
|
|
321
|
-
|
|
331
|
+
// @__NO_SIDE_EFFECTS__
|
|
322
332
|
function withDefault(schema, defaultValue) {
|
|
323
333
|
return {
|
|
324
334
|
...schema,
|
|
@@ -344,7 +354,7 @@ function withDefault(schema, defaultValue) {
|
|
|
344
354
|
*
|
|
345
355
|
* @experimental
|
|
346
356
|
*/
|
|
347
|
-
|
|
357
|
+
// @__NO_SIDE_EFFECTS__
|
|
348
358
|
function multiple(schema) {
|
|
349
359
|
return {
|
|
350
360
|
...schema,
|
|
@@ -370,7 +380,7 @@ function multiple(schema) {
|
|
|
370
380
|
*
|
|
371
381
|
* @experimental
|
|
372
382
|
*/
|
|
373
|
-
|
|
383
|
+
// @__NO_SIDE_EFFECTS__
|
|
374
384
|
function required(schema) {
|
|
375
385
|
return {
|
|
376
386
|
...schema,
|
|
@@ -399,7 +409,7 @@ function required(schema) {
|
|
|
399
409
|
*
|
|
400
410
|
* @experimental
|
|
401
411
|
*/
|
|
402
|
-
|
|
412
|
+
// @__NO_SIDE_EFFECTS__
|
|
403
413
|
function short(schema, alias) {
|
|
404
414
|
return {
|
|
405
415
|
...schema,
|
|
@@ -427,7 +437,7 @@ function short(schema, alias) {
|
|
|
427
437
|
*
|
|
428
438
|
* @experimental
|
|
429
439
|
*/
|
|
430
|
-
|
|
440
|
+
// @__NO_SIDE_EFFECTS__
|
|
431
441
|
function describe(schema, text) {
|
|
432
442
|
return {
|
|
433
443
|
...schema,
|
|
@@ -435,12 +445,40 @@ function describe(schema, text) {
|
|
|
435
445
|
};
|
|
436
446
|
}
|
|
437
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
|
+
/**
|
|
438
475
|
* Mark a combinator schema as not required.
|
|
439
476
|
*
|
|
440
|
-
* Useful for overriding a base combinator that was created with `required: true
|
|
477
|
+
* Useful for overriding a base combinator that was created with `required: true`,
|
|
478
|
+
* or for making a positional argument explicitly optional.
|
|
441
479
|
* The original schema is not modified.
|
|
442
480
|
*
|
|
443
|
-
* @typeParam T - The schema
|
|
481
|
+
* @typeParam T - The schema type.
|
|
444
482
|
*
|
|
445
483
|
* @param schema - The base combinator schema.
|
|
446
484
|
* @returns A new schema with `required: false`.
|
|
@@ -448,13 +486,14 @@ function describe(schema, text) {
|
|
|
448
486
|
* @example
|
|
449
487
|
* ```ts
|
|
450
488
|
* const args = {
|
|
451
|
-
* name: unrequired(string({ required: true }))
|
|
489
|
+
* name: unrequired(string({ required: true })),
|
|
490
|
+
* query: unrequired(positional())
|
|
452
491
|
* }
|
|
453
492
|
* ```
|
|
454
493
|
*
|
|
455
494
|
* @experimental
|
|
456
495
|
*/
|
|
457
|
-
|
|
496
|
+
// @__NO_SIDE_EFFECTS__
|
|
458
497
|
function unrequired(schema) {
|
|
459
498
|
return {
|
|
460
499
|
...schema,
|
|
@@ -482,11 +521,11 @@ function unrequired(schema) {
|
|
|
482
521
|
*
|
|
483
522
|
* @experimental
|
|
484
523
|
*/
|
|
485
|
-
|
|
524
|
+
// @__NO_SIDE_EFFECTS__
|
|
486
525
|
function args(fields) {
|
|
487
526
|
return fields;
|
|
488
527
|
}
|
|
489
|
-
|
|
528
|
+
// @__NO_SIDE_EFFECTS__
|
|
490
529
|
function merge(...schemas) {
|
|
491
530
|
const result = Object.create(null);
|
|
492
531
|
for (const schema of schemas) for (const key of Object.keys(schema)) result[key] = schema[key];
|
|
@@ -513,7 +552,7 @@ function merge(...schemas) {
|
|
|
513
552
|
*
|
|
514
553
|
* @experimental
|
|
515
554
|
*/
|
|
516
|
-
|
|
555
|
+
// @__NO_SIDE_EFFECTS__
|
|
517
556
|
function extend(base, overrides) {
|
|
518
557
|
const result = Object.create(null);
|
|
519
558
|
for (const key of Object.keys(base)) result[key] = base[key];
|
|
@@ -527,4 +566,4 @@ function extend(base, overrides) {
|
|
|
527
566
|
* @license MIT
|
|
528
567
|
*/
|
|
529
568
|
//#endregion
|
|
530
|
-
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
|
*
|
|
@@ -349,6 +349,8 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
349
349
|
const errors = [];
|
|
350
350
|
const explicit = Object.create(null);
|
|
351
351
|
const actualInputNames = /* @__PURE__ */ new Map();
|
|
352
|
+
const argEntries = Object.entries(args);
|
|
353
|
+
let requiredPositionalsAfter;
|
|
352
354
|
function checkTokenName(option, schema, token) {
|
|
353
355
|
return token.name === (schema.type === "boolean" ? schema.negatable && token.name?.startsWith("no-") ? `no-${option}` : option : option);
|
|
354
356
|
}
|
|
@@ -356,39 +358,63 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
356
358
|
function getPositionalSkipIndex() {
|
|
357
359
|
return Math.min(skipPositionalIndex, positionalItemCount);
|
|
358
360
|
}
|
|
361
|
+
function getRequiredPositionalsAfter(rawArg) {
|
|
362
|
+
requiredPositionalsAfter ??= createRequiredPositionalsAfter(argEntries);
|
|
363
|
+
return requiredPositionalsAfter[rawArg] ?? 0;
|
|
364
|
+
}
|
|
359
365
|
let positionalsCount = 0;
|
|
360
|
-
for (const [rawArg, schema] of
|
|
366
|
+
for (const [rawArg, schema] of argEntries) {
|
|
361
367
|
const arg = toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
|
|
362
368
|
explicit[rawArg] = false;
|
|
363
369
|
if (schema.type === "positional") {
|
|
364
370
|
if (skipPositionalIndex > SKIP_POSITIONAL_DEFAULT) while (positionalsCount <= getPositionalSkipIndex()) positionalsCount++;
|
|
365
371
|
if (schema.multiple) {
|
|
366
|
-
const
|
|
367
|
-
if (
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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;
|
|
374
393
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
explicit[rawArg] = true;
|
|
394
|
+
positionalsCount = endPositionals;
|
|
395
|
+
explicit[rawArg] = true;
|
|
396
|
+
} else if (schema.required) errors.push(createRequireError(arg, schema));
|
|
379
397
|
} else if (schema.required) errors.push(createRequireError(arg, schema));
|
|
380
398
|
} else {
|
|
381
399
|
const positional = positionalTokens[positionalsCount];
|
|
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
|
+
}
|
|
382
408
|
if (positional != null) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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;
|
|
387
415
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
} else errors.push(createRequireError(arg, schema));
|
|
391
|
-
positionalsCount++;
|
|
416
|
+
}
|
|
417
|
+
if (hasDefault(schema)) values[rawArg] = schema.default;
|
|
392
418
|
}
|
|
393
419
|
continue;
|
|
394
420
|
}
|
|
@@ -457,6 +483,38 @@ function parse(token, option, schema) {
|
|
|
457
483
|
function createRequireError(option, schema) {
|
|
458
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);
|
|
459
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
|
+
}
|
|
494
|
+
function hasDefault(schema) {
|
|
495
|
+
return schema.default != null;
|
|
496
|
+
}
|
|
497
|
+
function shouldRequireMissingSinglePositional(schema) {
|
|
498
|
+
if (schema.required === true) return true;
|
|
499
|
+
if (schema.required === false) return false;
|
|
500
|
+
return !hasDefault(schema);
|
|
501
|
+
}
|
|
502
|
+
function getRequiredPositionalInputCount(schema) {
|
|
503
|
+
if (schema.type !== "positional") return 0;
|
|
504
|
+
if (schema.multiple) return schema.required === true ? 1 : 0;
|
|
505
|
+
return shouldRequireMissingSinglePositional(schema) ? 1 : 0;
|
|
506
|
+
}
|
|
507
|
+
function createRequiredPositionalsAfter(argEntries) {
|
|
508
|
+
const requiredPositionalsAfter = Object.create(null);
|
|
509
|
+
let minimumRequiredPositionals = 0;
|
|
510
|
+
for (let i = argEntries.length - 1; i >= 0; i--) {
|
|
511
|
+
const [rawArg, schema] = argEntries[i];
|
|
512
|
+
if (schema.type !== "positional") continue;
|
|
513
|
+
requiredPositionalsAfter[rawArg] = minimumRequiredPositionals;
|
|
514
|
+
minimumRequiredPositionals += getRequiredPositionalInputCount(schema);
|
|
515
|
+
}
|
|
516
|
+
return requiredPositionalsAfter;
|
|
517
|
+
}
|
|
460
518
|
/**
|
|
461
519
|
* An error that occurs when resolving arguments.
|
|
462
520
|
* This error is thrown when the argument is not valid.
|
|
@@ -506,7 +564,7 @@ function checkConflicts(args, explicit, toKebab, actualInputNames) {
|
|
|
506
564
|
return [];
|
|
507
565
|
}
|
|
508
566
|
//#endregion
|
|
509
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
567
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.27.0/node_modules/args-tokens/lib/index.js
|
|
510
568
|
/**
|
|
511
569
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
512
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,13 +199,35 @@ 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
|
*
|
|
205
224
|
* When `true`, the argument must be provided by the user.
|
|
206
225
|
* If missing, an `ArgResolveError` with type 'required' will be thrown.
|
|
207
226
|
*
|
|
208
|
-
*
|
|
227
|
+
* For single-value positional arguments, omitting `required` keeps the argument
|
|
228
|
+
* required for compatibility. Set `required: false` to make a positional argument
|
|
229
|
+
* optional. Optional positional arguments leave enough input values for later
|
|
230
|
+
* required positional arguments before consuming a value.
|
|
209
231
|
*
|
|
210
232
|
* @example
|
|
211
233
|
* Required arguments:
|
|
@@ -229,7 +251,8 @@ interface ArgSchema {
|
|
|
229
251
|
*
|
|
230
252
|
* When `true`, the resolved value becomes an array.
|
|
231
253
|
* For options: can be specified multiple times (--tag foo --tag bar)
|
|
232
|
-
* For positional: collects remaining positional arguments
|
|
254
|
+
* For positional: collects remaining positional arguments after preserving values for
|
|
255
|
+
* later required positional arguments.
|
|
233
256
|
*
|
|
234
257
|
* Note: Only `true` is allowed (not `false`) to make intent explicit.
|
|
235
258
|
*
|
|
@@ -309,7 +332,11 @@ interface ArgSchema {
|
|
|
309
332
|
* - `boolean` type: boolean default
|
|
310
333
|
* - `number` type: number default
|
|
311
334
|
* - `enum` type: must be one of the `choices` values
|
|
312
|
-
* - `positional`/`custom` type:
|
|
335
|
+
* - `positional`/`custom` type: string, boolean, or number default
|
|
336
|
+
*
|
|
337
|
+
* For single-value positional arguments, the default is used when the positional
|
|
338
|
+
* value is missing or when the value is preserved for later required positional
|
|
339
|
+
* arguments, unless `required: true` is set.
|
|
313
340
|
*
|
|
314
341
|
* @example
|
|
315
342
|
* Default values by type:
|
|
@@ -566,7 +593,8 @@ type FilterArgs<A extends Args, V extends Record<keyof A, unknown>, K extends ke
|
|
|
566
593
|
*
|
|
567
594
|
* @internal
|
|
568
595
|
*/
|
|
569
|
-
type FilterPositionalArgs<A extends Args, V extends Record<keyof A, unknown>> = { [Arg in keyof A as A[Arg]
|
|
596
|
+
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] };
|
|
597
|
+
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;
|
|
570
598
|
/**
|
|
571
599
|
* An arguments for {@link resolveArgs | resolve arguments}.
|
|
572
600
|
*/
|
|
@@ -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,13 +504,21 @@ 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
|
-
if (
|
|
498
|
-
|
|
510
|
+
if (arg.multiple) {
|
|
511
|
+
if (arg.required) elements.push(`<${name}>`);
|
|
512
|
+
elements.push(`[<${name}> ...]`);
|
|
513
|
+
} else elements.push(isRequiredSinglePositionalArg(arg) ? `<${name}>` : `[<${name}>]`);
|
|
499
514
|
return elements.join(" ");
|
|
500
515
|
}).join(" ") : "";
|
|
501
516
|
}
|
|
517
|
+
function isRequiredSinglePositionalArg(arg) {
|
|
518
|
+
if (arg.required === true) return true;
|
|
519
|
+
if (arg.required === false) return false;
|
|
520
|
+
return arg.default == null;
|
|
521
|
+
}
|
|
502
522
|
//#endregion
|
|
503
523
|
//#region ../plugin-renderer/src/validation.ts
|
|
504
524
|
/**
|
|
@@ -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/resources": "0.
|
|
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
|