gunshi 0.28.2 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/bone.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { B as Args, C as Prettify, D as ValidationErrorsDecorator, E as SubCommandable, H as ArgToken, R as ArgSchema, S as NormalizeToGunshiParams, T as RenderingOptions, _ 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 RendererDecorator, x as LazyCommand, y as GunshiParams, z as ArgValues } from "./types-Doxo8g3Y.js";
1
+ import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues } from "./resolver-BfQ_CoYR.js";
2
+ import { C as Prettify, D as ValidationErrorsDecorator, E as SubCommandable, S as NormalizeToGunshiParams, T as RenderingOptions, _ 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 RendererDecorator, x as LazyCommand, y as GunshiParams } from "./types-BBvkSkl2.js";
2
3
 
3
4
  //#region src/cli/bone.d.ts
4
5
  /**
package/lib/bone.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as cliCore } from "./core-C9P_Gd_f.js";
1
+ import { t as cliCore } from "./core-CoMdwsPo.js";
2
2
 
3
3
  //#region src/cli/bone.ts
4
4
  /**
@@ -1,6 +1,6 @@
1
- import { t as cliCore } from "./core-C9P_Gd_f.js";
1
+ import { t as cliCore } from "./core-CoMdwsPo.js";
2
2
  import { t as plugin } from "./core-eN5xmB3s.js";
3
- import { a as namespacedId, s as COMMON_ARGS, t as renderer } from "./src-CfO5ab2f.js";
3
+ import { a as namespacedId, s as COMMON_ARGS, t as renderer } from "./src-h66U0DWW.js";
4
4
 
5
5
  //#region ../plugin-global/src/types.ts
6
6
  /**
@@ -0,0 +1,639 @@
1
+ import { i as Args, n as ArgSchema } from "./resolver-BfQ_CoYR.js";
2
+
3
+ //#region ../../node_modules/.pnpm/args-tokens@0.24.1/node_modules/args-tokens/lib/combinators.d.ts
4
+ /**
5
+ * @author kazuya kawaguchi (a.k.a. kazupon)
6
+ * @license MIT
7
+ */
8
+
9
+ //#region src/combinators.d.ts
10
+ /**
11
+ * @author kazuya kawaguchi (a.k.a. kazupon)
12
+ * @license MIT
13
+ */
14
+ /**
15
+ * A combinator produced by combinator factory functions.
16
+ *
17
+ * @typeParam T - The parsed value type.
18
+ *
19
+ * @experimental
20
+ */
21
+ type Combinator<T> = {
22
+ /**
23
+ * The parse function that converts a string to the desired type.
24
+ *
25
+ * @param value - The input string value.
26
+ * @returns The parsed value of type T.
27
+ */
28
+ parse: (value: string) => T;
29
+ };
30
+ /**
31
+ * A schema produced by combinator factory functions.
32
+ * Any {@link ArgSchema} with a parse function qualifies.
33
+ *
34
+ * @typeParam T - The parsed value type.
35
+ *
36
+ * @experimental
37
+ */
38
+ type CombinatorSchema<T> = ArgSchema & Combinator<T>;
39
+ /**
40
+ * Common options shared by all base combinators.
41
+ *
42
+ * @experimental
43
+ */
44
+ interface BaseOptions {
45
+ /**
46
+ * Human-readable description for help text generation.
47
+ */
48
+ description?: string;
49
+ /**
50
+ * Single character short alias.
51
+ */
52
+ short?: string;
53
+ /**
54
+ * Mark as required.
55
+ */
56
+ required?: boolean;
57
+ }
58
+ /**
59
+ * Options for the {@link string} combinator.
60
+ *
61
+ * @experimental
62
+ */
63
+ interface StringOptions extends BaseOptions {
64
+ /**
65
+ * Minimum string length.
66
+ */
67
+ minLength?: number;
68
+ /**
69
+ * Maximum string length.
70
+ */
71
+ maxLength?: number;
72
+ /**
73
+ * Regular expression pattern the value must match.
74
+ */
75
+ pattern?: RegExp;
76
+ }
77
+ /**
78
+ * Create a string argument schema with optional validation.
79
+ *
80
+ * @param opts - Validation options.
81
+ * @returns A combinator schema that resolves to string.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * const args = {
86
+ * name: string({ minLength: 1, maxLength: 50 })
87
+ * }
88
+ * ```
89
+ *
90
+ * @experimental
91
+ */
92
+ declare function string(opts?: StringOptions): CombinatorSchema<string>;
93
+ /**
94
+ * Options for the {@link number} combinator.
95
+ *
96
+ * @experimental
97
+ */
98
+ interface NumberOptions extends BaseOptions {
99
+ /**
100
+ * Minimum value (inclusive).
101
+ */
102
+ min?: number;
103
+ /**
104
+ * Maximum value (inclusive).
105
+ */
106
+ max?: number;
107
+ }
108
+ /**
109
+ * Create a number argument schema with optional range validation.
110
+ *
111
+ * Accepts any numeric value (integer or float).
112
+ *
113
+ * @param opts - Range options.
114
+ * @returns A combinator schema that resolves to number.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * const args = {
119
+ * timeout: number({ min: 0, max: 30000 })
120
+ * }
121
+ * ```
122
+ *
123
+ * @experimental
124
+ */
125
+ declare function number(opts?: NumberOptions): CombinatorSchema<number>;
126
+ /**
127
+ * Options for the {@link integer} combinator.
128
+ *
129
+ * @experimental
130
+ */
131
+ interface IntegerOptions extends BaseOptions {
132
+ /**
133
+ * Minimum value (inclusive).
134
+ */
135
+ min?: number;
136
+ /**
137
+ * Maximum value (inclusive).
138
+ */
139
+ max?: number;
140
+ }
141
+ /**
142
+ * Create an integer argument schema with optional range validation.
143
+ *
144
+ * Only accepts integer values (no decimals).
145
+ *
146
+ * @param opts - Range options.
147
+ * @returns A combinator schema that resolves to number (integer).
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * const args = {
152
+ * retries: integer({ min: 0, max: 10 })
153
+ * }
154
+ * ```
155
+ *
156
+ * @experimental
157
+ */
158
+ declare function integer(opts?: IntegerOptions): CombinatorSchema<number>;
159
+ /**
160
+ * Options for the {@link float} combinator.
161
+ *
162
+ * @experimental
163
+ */
164
+ interface FloatOptions extends BaseOptions {
165
+ /**
166
+ * Minimum value (inclusive).
167
+ */
168
+ min?: number;
169
+ /**
170
+ * Maximum value (inclusive).
171
+ */
172
+ max?: number;
173
+ }
174
+ /**
175
+ * Create a floating-point argument schema with optional range validation.
176
+ *
177
+ * Rejects `NaN` and `Infinity` values.
178
+ *
179
+ * @param opts - Range options.
180
+ * @returns A combinator schema that resolves to number (float).
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * const args = {
185
+ * ratio: float({ min: 0, max: 1 })
186
+ * }
187
+ * ```
188
+ *
189
+ * @experimental
190
+ */
191
+ declare function float(opts?: FloatOptions): CombinatorSchema<number>;
192
+ /**
193
+ * Options for the {@link boolean} combinator.
194
+ *
195
+ * @experimental
196
+ */
197
+ interface BooleanOptions extends BaseOptions {
198
+ /**
199
+ * Enable negation with `--no-` prefix.
200
+ */
201
+ negatable?: boolean;
202
+ }
203
+ /**
204
+ * Create a boolean argument schema.
205
+ *
206
+ * Boolean arguments are existence-based. The resolver passes `"true"` or `"false"`
207
+ * to the parse function based on the presence or negation of the flag.
208
+ *
209
+ * @param opts - Boolean options.
210
+ * @returns A combinator schema for boolean flags.
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * const args = {
215
+ * color: boolean({ negatable: true })
216
+ * }
217
+ * // Usage: --color (true), --no-color (false)
218
+ * ```
219
+ *
220
+ * @experimental
221
+ */
222
+ declare function boolean(opts?: BooleanOptions): CombinatorSchema<boolean>;
223
+ /**
224
+ * Positional argument schema type.
225
+ */
226
+ type ArgSchemaPositionalType = {
227
+ type: 'positional';
228
+ };
229
+ /**
230
+ * Create a positional argument schema.
231
+ *
232
+ * Without a parser, resolves to string.
233
+ * With a parser (e.g., `positional(integer())`), resolves to the parser's return type.
234
+ *
235
+ * @typeParam T - The parser's resolved type.
236
+ *
237
+ * @param parser - The parser combinator schema.
238
+ * @returns A positional argument schema resolving to the parser's type.
239
+ *
240
+ * @example
241
+ * ```ts
242
+ * const args = {
243
+ * command: positional(), // resolves to string
244
+ * port: positional(integer()), // resolves to number
245
+ * }
246
+ * ```
247
+ *
248
+ * @experimental
249
+ */
250
+ declare function positional<T>(parser: CombinatorSchema<T>): CombinatorSchema<T> & ArgSchemaPositionalType;
251
+ /**
252
+ * Create a positional argument schema.
253
+ *
254
+ * Without a parser, resolves to string.
255
+ * With a parser (e.g., `positional(integer())`), resolves to the parser's return type.
256
+ *
257
+ * @param parser - Optional base options (description, short, required).
258
+ * @returns A positional argument schema resolving to string.
259
+ *
260
+ * @example
261
+ * ```ts
262
+ * const args = {
263
+ * command: positional(), // resolves to string
264
+ * port: positional(integer()), // resolves to number
265
+ * }
266
+ * ```
267
+ *
268
+ * @experimental
269
+ */
270
+ declare function positional(parser?: BaseOptions): ArgSchema & ArgSchemaPositionalType;
271
+ /**
272
+ * Create an enum-like argument schema with literal type inference.
273
+ *
274
+ * Uses `const T` generic to infer literal union types from the values array.
275
+ *
276
+ * @typeParam T - The readonly array of allowed string values.
277
+ *
278
+ * @param values - Allowed values.
279
+ * @param opts - Common options (description, short, required).
280
+ * @returns A combinator schema that resolves to a union of the allowed values.
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * const args = {
285
+ * level: choice(['debug', 'info', 'warn', 'error'] as const)
286
+ * }
287
+ * // typeof values.level === 'debug' | 'info' | 'warn' | 'error'
288
+ * ```
289
+ *
290
+ * @experimental
291
+ */
292
+ declare function choice<const T extends readonly string[]>(values: T, opts?: BaseOptions): CombinatorSchema<T[number]>;
293
+ /**
294
+ * Options for the {@link combinator} factory function.
295
+ *
296
+ * @typeParam T - The parsed value type.
297
+ *
298
+ * @experimental
299
+ */
300
+ interface CombinatorOptions<T> extends BaseOptions {
301
+ /**
302
+ * The parse function that converts a string to the desired type.
303
+ *
304
+ * @param value - The input string value.
305
+ * @returns The parsed value of type T.
306
+ */
307
+ parse: (value: string) => T;
308
+ /**
309
+ * Display name hint for help text generation.
310
+ *
311
+ * @default 'custom'
312
+ */
313
+ metavar?: string;
314
+ }
315
+ /**
316
+ * Create a custom argument schema with a user-defined parse function.
317
+ *
318
+ * This is the most general custom combinator. Use it when none of the built-in
319
+ * base combinators ({@link string}, {@link number}, {@link integer},
320
+ * {@link float}, {@link boolean}, {@link choice}) fit your needs.
321
+ *
322
+ * The returned schema has `type: 'custom'`.
323
+ *
324
+ * @typeParam T - The parsed value type.
325
+ *
326
+ * @param config - Configuration with a parse function and optional metavar.
327
+ * @returns A combinator schema that resolves to the parse function's return type.
328
+ *
329
+ * @example
330
+ * ```ts
331
+ * const date = combinator({
332
+ * parse: (value) => {
333
+ * const d = new Date(value)
334
+ * if (isNaN(d.getTime())) {
335
+ * throw new Error('Invalid date format')
336
+ * }
337
+ * return d
338
+ * },
339
+ * metavar: 'date'
340
+ * })
341
+ * ```
342
+ *
343
+ * @experimental
344
+ */
345
+ declare function combinator<T>(config: CombinatorOptions<T>): CombinatorSchema<T>;
346
+ /**
347
+ * Transform the output of a combinator schema.
348
+ *
349
+ * Creates a new schema that applies `transform` to the result of `schema.parse`.
350
+ * The original schema is not modified.
351
+ *
352
+ * @typeParam T - The input schema's parsed type.
353
+ * @typeParam U - The transformed type.
354
+ *
355
+ * @param schema - The base combinator schema.
356
+ * @param transform - The transformation function.
357
+ * @returns A new combinator schema that resolves to the transformed type.
358
+ *
359
+ * @example
360
+ * ```ts
361
+ * const args = {
362
+ * doubled: map(integer(), n => n * 2)
363
+ * }
364
+ * ```
365
+ *
366
+ * @experimental
367
+ */
368
+ declare function map<T, U>(schema: CombinatorSchema<T>, transform: (value: T) => U): CombinatorSchema<U>;
369
+ /**
370
+ * Options for the {@link withDefault} combinator.
371
+ */
372
+ type CombinatorWithDefault<T> = {
373
+ default: T;
374
+ };
375
+ /**
376
+ * Set a default value on a combinator schema.
377
+ *
378
+ * The original schema is not modified.
379
+ *
380
+ * @typeParam T - The schema's parsed type.
381
+ *
382
+ * @param schema - The base combinator schema.
383
+ * @param defaultValue - The default value.
384
+ * @returns A new schema with the default value set.
385
+ *
386
+ * @example
387
+ * ```ts
388
+ * const args = {
389
+ * port: withDefault(integer({ min: 1, max: 65535 }), 8080)
390
+ * }
391
+ * ```
392
+ *
393
+ * @experimental
394
+ */
395
+ declare function withDefault<T extends string | boolean | number>(schema: CombinatorSchema<T>, defaultValue: T): CombinatorSchema<T> & CombinatorWithDefault<T>;
396
+ /**
397
+ * Options for the {@link multiple} combinator.
398
+ */
399
+ type CombinatorMultiple = {
400
+ multiple: true;
401
+ };
402
+ /**
403
+ * Mark a combinator schema as accepting multiple values.
404
+ *
405
+ * The resolved value becomes an array. The original schema is not modified.
406
+ *
407
+ * @typeParam T - The schema's parsed type.
408
+ * @param schema - The base combinator schema.
409
+ * @returns A new schema with `multiple: true`.
410
+ *
411
+ * @example
412
+ * ```ts
413
+ * const args = {
414
+ * tags: multiple(string())
415
+ * }
416
+ * // typeof values.tags === string[]
417
+ * ```
418
+ *
419
+ * @experimental
420
+ */
421
+ declare function multiple<T>(schema: CombinatorSchema<T>): CombinatorSchema<T> & CombinatorMultiple;
422
+ /**
423
+ * Options for the {@link required} combinator.
424
+ */
425
+ type CombinatorRequired = {
426
+ required: true;
427
+ };
428
+ /**
429
+ * Mark a combinator schema as required.
430
+ *
431
+ * The original schema is not modified.
432
+ *
433
+ * @typeParam T - The schema's parsed type.
434
+ *
435
+ * @param schema - The base combinator schema.
436
+ * @returns A new schema with `required: true`.
437
+ *
438
+ * @example
439
+ * ```ts
440
+ * const args = {
441
+ * name: required(string())
442
+ * }
443
+ * ```
444
+ *
445
+ * @experimental
446
+ */
447
+ declare function required<T>(schema: CombinatorSchema<T>): CombinatorSchema<T> & CombinatorRequired;
448
+ /**
449
+ * Options for the {@link short} combinator.
450
+ */
451
+ type CombinatorShort<S extends string> = {
452
+ short: S;
453
+ };
454
+ /**
455
+ * Set a short alias on a combinator schema.
456
+ *
457
+ * The original schema is not modified.
458
+ *
459
+ * @typeParam T - The schema's parsed type.
460
+ * @typeParam S - The short alias string literal type.
461
+ *
462
+ * @param schema - The base combinator schema.
463
+ * @param alias - Single character short alias.
464
+ * @returns A new schema with the short alias set.
465
+ *
466
+ * @example
467
+ * ```ts
468
+ * const args = {
469
+ * verbose: short(boolean(), 'v')
470
+ * }
471
+ * // Usage: -v or --verbose
472
+ * ```
473
+ *
474
+ * @experimental
475
+ */
476
+ declare function short<T, S extends string>(schema: CombinatorSchema<T>, alias: S): CombinatorSchema<T> & CombinatorShort<S>;
477
+ /**
478
+ * Options for the {@link describe} combinator.
479
+ */
480
+ type CombinatorDescribe<D extends string> = {
481
+ description: D;
482
+ };
483
+ /**
484
+ * Set a description on a combinator schema for help text generation.
485
+ *
486
+ * The original schema is not modified.
487
+ *
488
+ * @typeParam T - The schema's parsed type.
489
+ * @typeParam D - The description string literal type.
490
+ *
491
+ * @param schema - The base combinator schema.
492
+ * @param text - Human-readable description.
493
+ * @returns A new schema with the description set.
494
+ *
495
+ * @example
496
+ * ```ts
497
+ * const args = {
498
+ * port: describe(integer(), 'Port number to listen on')
499
+ * }
500
+ * ```
501
+ *
502
+ * @experimental
503
+ */
504
+ declare function describe<T, D extends string>(schema: CombinatorSchema<T>, text: D): CombinatorSchema<T> & CombinatorDescribe<D>;
505
+ /**
506
+ * Options for the {@link unrequired} combinator.
507
+ */
508
+ type CombinatorUnrequired = {
509
+ required: false;
510
+ };
511
+ /**
512
+ * Mark a combinator schema as not required.
513
+ *
514
+ * Useful for overriding a base combinator that was created with `required: true`.
515
+ * The original schema is not modified.
516
+ *
517
+ * @typeParam T - The schema's parsed type.
518
+ *
519
+ * @param schema - The base combinator schema.
520
+ * @returns A new schema with `required: false`.
521
+ *
522
+ * @example
523
+ * ```ts
524
+ * const args = {
525
+ * name: unrequired(string({ required: true }))
526
+ * }
527
+ * ```
528
+ *
529
+ * @experimental
530
+ */
531
+ declare function unrequired<T>(schema: CombinatorSchema<T>): CombinatorSchema<T> & CombinatorUnrequired;
532
+ /**
533
+ * Recursively merge a tuple of {@link Args} types.
534
+ * Later types override earlier ones on key conflicts.
535
+ *
536
+ * @internal
537
+ */
538
+ type MergeArgs<T extends Args[]> = T extends [infer Only extends Args] ? Only : T extends [infer First extends Args, ...infer Rest extends Args[]] ? Omit<First, keyof MergeArgs<Rest>> & MergeArgs<Rest> : never;
539
+ /**
540
+ * Type-safe schema factory.
541
+ *
542
+ * Returns the input unchanged at runtime, but provides type inference
543
+ * so that `satisfies Args` is not needed.
544
+ *
545
+ * @typeParam T - The exact schema type.
546
+ *
547
+ * @param fields - The argument schema object.
548
+ * @returns The same schema object with its type inferred.
549
+ *
550
+ * @example
551
+ * ```ts
552
+ * const common = args({
553
+ * verbose: boolean(),
554
+ * help: short(boolean(), 'h')
555
+ * })
556
+ * ```
557
+ *
558
+ * @experimental
559
+ */
560
+ declare function args<T extends Args>(fields: T): T;
561
+ /**
562
+ * Compose multiple {@link Args} schemas into one.
563
+ *
564
+ * On key conflicts the later schema wins (last-write-wins).
565
+ *
566
+ * @typeParam A - First schema type.
567
+ * @typeParam B - Second schema type.
568
+ *
569
+ * @param a - First schema.
570
+ * @param b - Second schema.
571
+ * @returns A merged schema containing all fields.
572
+ *
573
+ * @example
574
+ * ```ts
575
+ * const common = args({ verbose: boolean() })
576
+ * const network = args({ host: required(string()), port: withDefault(integer(), 8080) })
577
+ * const schema = merge(common, network)
578
+ * ```
579
+ *
580
+ * @experimental
581
+ */
582
+ declare function merge<A extends Args, B extends Args>(a: A, b: B): Omit<A, keyof B> & B;
583
+ /**
584
+ * Compose multiple {@link Args} schemas into one.
585
+ *
586
+ * @param a - First schema.
587
+ * @param b - Second schema.
588
+ * @param c - Third schema.
589
+ * @returns A merged schema containing all fields.
590
+ *
591
+ * @experimental
592
+ */
593
+ declare function merge<A extends Args, B extends Args, C extends Args>(a: A, b: B, c: C): Omit<Omit<A, keyof B | keyof C> & Omit<B, keyof C>, never> & C;
594
+ /**
595
+ * Compose multiple {@link Args} schemas into one.
596
+ *
597
+ * @param a - First schema.
598
+ * @param b - Second schema.
599
+ * @param c - Third schema.
600
+ * @param d - Fourth schema.
601
+ * @returns A merged schema containing all fields.
602
+ *
603
+ * @experimental
604
+ */
605
+ declare function merge<A extends Args, B extends Args, C extends Args, D extends Args>(a: A, b: B, c: C, d: D): MergeArgs<[A, B, C, D]>;
606
+ /**
607
+ * Compose multiple {@link Args} schemas into one.
608
+ *
609
+ * @param schemas - The schemas to merge.
610
+ * @returns A merged schema containing all fields.
611
+ *
612
+ * @experimental
613
+ */
614
+ declare function merge<T extends Args[]>(...schemas: T): MergeArgs<T>;
615
+ /**
616
+ * Extend a schema by overriding or adding fields.
617
+ *
618
+ * Equivalent to `merge(base, overrides)` but communicates the intent of
619
+ * intentional overrides rather than general composition.
620
+ *
621
+ * @typeParam T - Base schema type.
622
+ * @typeParam U - Overrides schema type.
623
+ *
624
+ * @param base - The base schema to extend.
625
+ * @param overrides - Fields to override or add.
626
+ * @returns A new schema with overrides applied.
627
+ *
628
+ * @example
629
+ * ```ts
630
+ * const base = args({ port: withDefault(integer(), 8080) })
631
+ * const strict = extend(base, { port: required(integer({ min: 1, max: 65535 })) })
632
+ * ```
633
+ *
634
+ * @experimental
635
+ */
636
+ declare function extend<T extends Args, U extends Args>(base: T, overrides: U): Omit<T, keyof U> & U;
637
+ //#endregion
638
+ //#endregion
639
+ 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 };