gunshi 0.37.0 → 0.37.2

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/agent.js CHANGED
@@ -1,5 +1,8 @@
1
1
  //#region ../../node_modules/.pnpm/std-env@4.1.0/node_modules/std-env/dist/index.mjs
2
- const e = globalThis.process?.env || Object.create(null), t = globalThis.process || { env: e }, n = t !== void 0 && t.env && t.env.NODE_ENV || void 0, r = [
2
+ const e = globalThis.process?.env || Object.create(null);
3
+ const t = globalThis.process || { env: e };
4
+ const n = t !== void 0 && t.env && t.env.NODE_ENV || void 0;
5
+ const r = [
3
6
  [`claude`, [`CLAUDECODE`, `CLAUDE_CODE`]],
4
7
  [`replit`, [`REPL_ID`]],
5
8
  [`gemini`, [`GEMINI_CLI`]],
@@ -160,7 +163,14 @@ const S = /^win/i.test(p);
160
163
  !e.NO_COLOR && (e.FORCE_COLOR || (h || S) && e.TERM);
161
164
  const E = (t.versions?.node || ``).replace(/^v/, ``) || null;
162
165
  Number(E?.split(`.`)[0]);
163
- const O = !!t?.versions?.node, k = `Bun` in globalThis, A = `Deno` in globalThis, j = `fastly` in globalThis, M = `Netlify` in globalThis, N = `EdgeRuntime` in globalThis, P = globalThis.navigator?.userAgent === `Cloudflare-Workers`, F = [
166
+ const O = !!t?.versions?.node;
167
+ const k = `Bun` in globalThis;
168
+ const A = `Deno` in globalThis;
169
+ const j = `fastly` in globalThis;
170
+ const M = `Netlify` in globalThis;
171
+ const N = `EdgeRuntime` in globalThis;
172
+ const P = globalThis.navigator?.userAgent === `Cloudflare-Workers`;
173
+ const F = [
164
174
  [M, `netlify`],
165
175
  [N, `edge-light`],
166
176
  [P, `workerd`],
package/lib/bone.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { i as Args, n as ArgSchema, r as ArgValues, u as ArgToken } from "./resolver-CgkhQ6Tt.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-CD5eRJFK.js";
1
+ import { i as Args, n as ArgSchema, r as ArgValues, u as ArgToken } from "./resolver-D7DEcpu-.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-CdM9C6VD.js";
3
3
 
4
4
  //#region src/cli/bone.d.ts
5
5
  /**
package/lib/bone.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as cliCore } from "./core-CbE1I4Jl.js";
1
+ import { t as cliCore } from "./core-Ce6x0is5.js";
2
2
  //#region src/cli/bone.ts
3
3
  /**
4
4
  * @author kazuya kawaguchi (a.k.a. kazupon)
@@ -1,7 +1,7 @@
1
- import { r as hasPriorityValidationError } from "./error-xSnOOdnr.js";
2
- import { t as plugin } from "./plugin-DhJZVIbl.js";
3
- import { a as namespacedId, o as COMMON_ARGS, t as renderer } from "./src-DIz-QFuo.js";
4
- import { t as cliCore } from "./core-CbE1I4Jl.js";
1
+ import { r as hasPriorityValidationError } from "./error-CBijJN5L.js";
2
+ import { t as plugin } from "./plugin-Cvf6mYto.js";
3
+ import { a as namespacedId, o as COMMON_ARGS, t as renderer } from "./src-yiBqxwCm.js";
4
+ import { t as cliCore } from "./core-Ce6x0is5.js";
5
5
  //#region ../plugin-global/src/types.ts
6
6
  /**
7
7
  * @author kazuya kawaguchi (a.k.a. kazupon)
@@ -160,7 +160,8 @@ function global() {
160
160
  * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
161
161
  */
162
162
  async function cli(args, entry, options = {}) {
163
- return cliCore(args, entry, options, [global(), renderer()]);
163
+ const builtInPlugins = [global(), renderer()];
164
+ return cliCore(args, entry, options, builtInPlugins);
164
165
  }
165
166
  //#endregion
166
167
  //#region src/cli.ts
@@ -1,6 +1,6 @@
1
- import { i as Args, n as ArgSchema } from "./resolver-CgkhQ6Tt.js";
1
+ import { i as Args, n as ArgSchema } from "./resolver-D7DEcpu-.js";
2
2
 
3
- //#region ../../node_modules/.pnpm/args-tokens@0.28.0/node_modules/args-tokens/lib/combinators.d.ts
3
+ //#region ../../node_modules/.pnpm/args-tokens@0.28.2/node_modules/args-tokens/lib/combinators.d.ts
4
4
 
5
5
  //#region src/combinators.d.ts
6
6
  /**
@@ -391,6 +391,13 @@ type CombinatorWithDefault<T> = {
391
391
  * @experimental
392
392
  */
393
393
  declare function withDefault<T extends string | boolean | number>(schema: CombinatorSchema<T>, defaultValue: T): CombinatorSchema<T> & CombinatorWithDefault<T>;
394
+ /**
395
+ * Overlay a flag onto a combinator schema without dropping other modifiers.
396
+ *
397
+ * Omits the flag keys from `S` first so optional `ArgSchema` fields
398
+ * (`multiple?: true`, `required?: boolean`) cannot stay as unions.
399
+ */
400
+ type WithFlag<S, F> = Omit<S, keyof F> & F;
394
401
  /**
395
402
  * Options for the {@link multiple} combinator.
396
403
  */
@@ -401,10 +408,11 @@ type CombinatorMultiple = {
401
408
  * Mark a combinator schema as accepting multiple values.
402
409
  *
403
410
  * The resolved value becomes an array. The original schema is not modified.
411
+ * Other modifiers on `schema` (for example {@link required}) are kept.
404
412
  *
405
- * @typeParam T - The schema's parsed type.
413
+ * @typeParam S - The input combinator schema.
406
414
  * @param schema - The base combinator schema.
407
- * @returns A new schema with `multiple: true`.
415
+ * @returns A copy of `schema` with `multiple: true`.
408
416
  *
409
417
  * @example
410
418
  * ```ts
@@ -416,7 +424,7 @@ type CombinatorMultiple = {
416
424
  *
417
425
  * @experimental
418
426
  */
419
- declare function multiple<T>(schema: CombinatorSchema<T>): CombinatorSchema<T> & CombinatorMultiple;
427
+ declare function multiple<S extends CombinatorSchema<unknown>>(schema: S): WithFlag<S, CombinatorMultiple>;
420
428
  /**
421
429
  * Options for the {@link required} combinator.
422
430
  */
@@ -427,11 +435,12 @@ type CombinatorRequired = {
427
435
  * Mark a combinator schema as required.
428
436
  *
429
437
  * The original schema is not modified.
438
+ * Other modifiers on `schema` (for example {@link multiple}) are kept.
430
439
  *
431
- * @typeParam T - The schema's parsed type.
440
+ * @typeParam S - The input combinator schema.
432
441
  *
433
442
  * @param schema - The base combinator schema.
434
- * @returns A new schema with `required: true`.
443
+ * @returns A copy of `schema` with `required: true`.
435
444
  *
436
445
  * @example
437
446
  * ```ts
@@ -442,7 +451,7 @@ type CombinatorRequired = {
442
451
  *
443
452
  * @experimental
444
453
  */
445
- declare function required<T>(schema: CombinatorSchema<T>): CombinatorSchema<T> & CombinatorRequired;
454
+ declare function required<S extends CombinatorSchema<unknown>>(schema: S): WithFlag<S, CombinatorRequired>;
446
455
  /**
447
456
  * Options for the {@link short} combinator.
448
457
  */
@@ -1,6 +1,6 @@
1
- import { t as formatChoices } from "./utils-BKhsrjPW.js";
2
- import { n as ArgsValidationErrorKeys, t as ArgsValidationError } from "./resolver-UFOtObbe.js";
3
- //#region ../../node_modules/.pnpm/args-tokens@0.28.0/node_modules/args-tokens/lib/combinators.js
1
+ import { t as formatChoices } from "./utils-oPJNnmOb.js";
2
+ import { n as ArgsValidationErrorKeys, t as ArgsValidationError } from "./resolver-dsINFnU2.js";
3
+ //#region ../../node_modules/.pnpm/args-tokens@0.28.2/node_modules/args-tokens/lib/combinators.js
4
4
  /**
5
5
  * Parser combinator factory functions for composable argument schema construction.
6
6
  *
@@ -412,10 +412,11 @@ function withDefault(schema, defaultValue) {
412
412
  * Mark a combinator schema as accepting multiple values.
413
413
  *
414
414
  * The resolved value becomes an array. The original schema is not modified.
415
+ * Other modifiers on `schema` (for example {@link required}) are kept.
415
416
  *
416
- * @typeParam T - The schema's parsed type.
417
+ * @typeParam S - The input combinator schema.
417
418
  * @param schema - The base combinator schema.
418
- * @returns A new schema with `multiple: true`.
419
+ * @returns A copy of `schema` with `multiple: true`.
419
420
  *
420
421
  * @example
421
422
  * ```ts
@@ -438,11 +439,12 @@ function multiple(schema) {
438
439
  * Mark a combinator schema as required.
439
440
  *
440
441
  * The original schema is not modified.
442
+ * Other modifiers on `schema` (for example {@link multiple}) are kept.
441
443
  *
442
- * @typeParam T - The schema's parsed type.
444
+ * @typeParam S - The input combinator schema.
443
445
  *
444
446
  * @param schema - The base combinator schema.
445
- * @returns A new schema with `required: true`.
447
+ * @returns A copy of `schema` with `required: true`.
446
448
  *
447
449
  * @example
448
450
  * ```ts
package/lib/context.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { i as Args, r as ArgValues, u as ArgToken } from "./resolver-CgkhQ6Tt.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-CD5eRJFK.js";
1
+ import { i as Args, r as ArgValues, u as ArgToken } from "./resolver-D7DEcpu-.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-CdM9C6VD.js";
3
3
 
4
4
  //#region src/context.d.ts
5
5
 
@@ -1,8 +1,8 @@
1
1
  import { i as NOOP, r as CLI_OPTIONS_DEFAULT, t as createCommandContext } from "./context-CAPhwgJJ.js";
2
- import { n as kebabnize } from "./utils-BKhsrjPW.js";
2
+ import { n as kebabnize } from "./utils-oPJNnmOb.js";
3
3
  import { create, getCommandSubCommands, isLazyCommand, resolveLazyCommand } from "./utils.js";
4
- import { a as parseArgs, i as resolveArgs, n as ArgsValidationErrorKeys, t as ArgsValidationError } from "./resolver-UFOtObbe.js";
5
- import { n as CommandNotFoundErrorKeys, r as hasPriorityValidationError, t as CommandNotFoundError } from "./error-xSnOOdnr.js";
4
+ import { a as parseArgs, i as resolveArgs, n as ArgsValidationErrorKeys, t as ArgsValidationError } from "./resolver-dsINFnU2.js";
5
+ import { n as CommandNotFoundErrorKeys, r as hasPriorityValidationError, t as CommandNotFoundError } from "./error-CBijJN5L.js";
6
6
  //#region src/decorators.ts
7
7
  /**
8
8
  * @author kazuya kawaguchi (a.k.a. kazupon)
@@ -361,27 +361,28 @@ function getPositionalTokens(tokens) {
361
361
  function resolveCommandTree(tokens, entry, options) {
362
362
  const positionals = getPositionalTokens(tokens);
363
363
  function resolveAsEntry() {
364
- if (typeof entry === "function") if ("commandName" in entry && entry.commandName) return {
365
- commandName: entry.commandName,
366
- command: entry,
367
- callMode: "entry",
368
- commandPath: [],
369
- depth: 0,
370
- omitted: options.subCommands.size > 0 && !positionals[0],
371
- levelSubCommands: options.subCommands.size > 0 ? options.subCommands : void 0
372
- };
373
- else return {
374
- command: {
375
- run: entry,
376
- entry: true
377
- },
378
- callMode: "entry",
379
- commandPath: [],
380
- depth: 0,
381
- omitted: options.subCommands.size > 0 && !positionals[0],
382
- levelSubCommands: options.subCommands.size > 0 ? options.subCommands : void 0
383
- };
384
- else if (typeof entry === "object") return {
364
+ if (typeof entry === "function") {
365
+ if ("commandName" in entry && entry.commandName) return {
366
+ commandName: entry.commandName,
367
+ command: entry,
368
+ callMode: "entry",
369
+ commandPath: [],
370
+ depth: 0,
371
+ omitted: options.subCommands.size > 0 && !positionals[0],
372
+ levelSubCommands: options.subCommands.size > 0 ? options.subCommands : void 0
373
+ };
374
+ else return {
375
+ command: {
376
+ run: entry,
377
+ entry: true
378
+ },
379
+ callMode: "entry",
380
+ commandPath: [],
381
+ depth: 0,
382
+ omitted: options.subCommands.size > 0 && !positionals[0],
383
+ levelSubCommands: options.subCommands.size > 0 ? options.subCommands : void 0
384
+ };
385
+ } else if (typeof entry === "object") return {
385
386
  commandName: resolveEntryName(entry),
386
387
  command: entry,
387
388
  callMode: "entry",
@@ -1,5 +1,5 @@
1
- import { i as Args, n as ArgSchema, r as ArgValues } from "./resolver-CgkhQ6Tt.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-CD5eRJFK.js";
1
+ import { i as Args, n as ArgSchema, r as ArgValues } from "./resolver-D7DEcpu-.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-CdM9C6VD.js";
3
3
  import { CommandContextParams, createCommandContext } from "./context.js";
4
4
 
5
5
  //#region src/definition.d.ts
@@ -1,5 +1,5 @@
1
- import { n as ArgsValidationErrorKeys, r as isArgsValidationError } from "./resolver-UFOtObbe.js";
2
- //#region ../../node_modules/.pnpm/args-tokens@0.28.0/node_modules/args-tokens/lib/index.js
1
+ import { n as ArgsValidationErrorKeys, r as isArgsValidationError } from "./resolver-dsINFnU2.js";
2
+ //#region ../../node_modules/.pnpm/args-tokens@0.28.2/node_modules/args-tokens/lib/index.js
3
3
  /**
4
4
  * @author kazuya kawaguchi (a.k.a. kazupon)
5
5
  * @license MIT
@@ -1,4 +1,4 @@
1
- import { m as DefaultGunshiParams, n as CliOptions } from "./types-CD5eRJFK.js";
1
+ import { m as DefaultGunshiParams, n as CliOptions } from "./types-CdM9C6VD.js";
2
2
 
3
3
  //#region src/constants.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { b as GunshiParamsConstraint, m as DefaultGunshiParams, n as CliOptions, r as Command, x as LazyCommand } from "./types-CD5eRJFK.js";
1
+ import { b as GunshiParamsConstraint, m as DefaultGunshiParams, n as CliOptions, r as Command, x as LazyCommand } from "./types-CdM9C6VD.js";
2
2
 
3
3
  //#region src/generator.d.ts
4
4
 
package/lib/generator.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { create } from "./utils.js";
2
- import { t as cli } from "./cli-C4_IDXMQ.js";
2
+ import { t as cli } from "./cli-xU__0QWJ.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 ArgsValidationError, c as isArgsValidationError, d as parseArgs, i as Args, l as resolveArgs, n as ArgSchema, o as ArgsValidationErrorCode, r as ArgValues, s as ArgsValidationErrorKeys, u as ArgToken } from "./resolver-CgkhQ6Tt.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-CD5eRJFK.js";
1
+ import { a as ArgsValidationError, c as isArgsValidationError, d as parseArgs, i as Args, l as resolveArgs, n as ArgSchema, o as ArgsValidationErrorCode, r as ArgValues, s as ArgsValidationErrorKeys, u as ArgToken } from "./resolver-D7DEcpu-.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-CdM9C6VD.js";
3
3
  import { CommandContextParams, createCommandContext } from "./context.js";
4
4
  import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition.js";
5
- import { a as hasPriorityValidationError, i as CommandNotFoundErrorOptions, n as CommandNotFoundErrorCode, o as isCommandNotFoundError, r as CommandNotFoundErrorKeys, s as ANONYMOUS_COMMAND_NAME, t as CommandNotFoundError } from "./error-6srXBX7u.js";
5
+ import { a as hasPriorityValidationError, i as CommandNotFoundErrorOptions, n as CommandNotFoundErrorCode, o as isCommandNotFoundError, r as CommandNotFoundErrorKeys, s as ANONYMOUS_COMMAND_NAME, t as CommandNotFoundError } from "./error-Ck8cJsi0.js";
6
6
 
7
7
  //#region ../plugin-i18n/src/types.d.ts
8
8
  /**
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { n as ANONYMOUS_COMMAND_NAME, t as createCommandContext } from "./context-CAPhwgJJ.js";
2
- import { a as parseArgs, i as resolveArgs, n as ArgsValidationErrorKeys, r as isArgsValidationError, t as ArgsValidationError } from "./resolver-UFOtObbe.js";
3
- import { i as isCommandNotFoundError, n as CommandNotFoundErrorKeys, r as hasPriorityValidationError, t as CommandNotFoundError } from "./error-xSnOOdnr.js";
4
- import { t as plugin } from "./plugin-DhJZVIbl.js";
5
- import { a as namespacedId } from "./src-DIz-QFuo.js";
6
- import { t as cli } from "./cli-C4_IDXMQ.js";
2
+ import { a as parseArgs, i as resolveArgs, n as ArgsValidationErrorKeys, r as isArgsValidationError, t as ArgsValidationError } from "./resolver-dsINFnU2.js";
3
+ import { i as isCommandNotFoundError, n as CommandNotFoundErrorKeys, r as hasPriorityValidationError, t as CommandNotFoundError } from "./error-CBijJN5L.js";
4
+ import { t as plugin } from "./plugin-Cvf6mYto.js";
5
+ import { a as namespacedId } from "./src-yiBqxwCm.js";
6
+ import { t as cli } from "./cli-xU__0QWJ.js";
7
7
  import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition.js";
8
8
  //#region ../plugin-i18n/src/translation.ts
9
9
  /**
@@ -1,4 +1,4 @@
1
- import "./error-xSnOOdnr.js";
1
+ import "./error-CBijJN5L.js";
2
2
  //#region src/plugin/core.ts
3
3
  /**
4
4
  * @author kazuya kawaguchi (a.k.a. kazupon)
package/lib/plugin.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { a as ArgsValidationError, c as isArgsValidationError, i as Args, n as ArgSchema, o as ArgsValidationErrorCode, r as ArgValues, s as ArgsValidationErrorKeys, u as ArgToken } from "./resolver-CgkhQ6Tt.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-CD5eRJFK.js";
1
+ import { a as ArgsValidationError, c as isArgsValidationError, i as Args, n as ArgSchema, o as ArgsValidationErrorCode, r as ArgValues, s as ArgsValidationErrorKeys, u as ArgToken } from "./resolver-D7DEcpu-.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-CdM9C6VD.js";
3
3
  import { CommandContextParams, createCommandContext } from "./context.js";
4
- import { a as hasPriorityValidationError, c as CLI_OPTIONS_DEFAULT, i as CommandNotFoundErrorOptions, n as CommandNotFoundErrorCode, o as isCommandNotFoundError, r as CommandNotFoundErrorKeys, s as ANONYMOUS_COMMAND_NAME, t as CommandNotFoundError } from "./error-6srXBX7u.js";
4
+ import { a as hasPriorityValidationError, c as CLI_OPTIONS_DEFAULT, i as CommandNotFoundErrorOptions, n as CommandNotFoundErrorCode, o as isCommandNotFoundError, r as CommandNotFoundErrorKeys, s as ANONYMOUS_COMMAND_NAME, t as CommandNotFoundError } from "./error-Ck8cJsi0.js";
5
5
 
6
6
  //#region src/plugin.d.ts
7
7
  /**
package/lib/plugin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as ANONYMOUS_COMMAND_NAME, r as CLI_OPTIONS_DEFAULT, t as createCommandContext } from "./context-CAPhwgJJ.js";
2
- import { n as ArgsValidationErrorKeys, r as isArgsValidationError, t as ArgsValidationError } from "./resolver-UFOtObbe.js";
3
- import { i as isCommandNotFoundError, n as CommandNotFoundErrorKeys, r as hasPriorityValidationError, t as CommandNotFoundError } from "./error-xSnOOdnr.js";
4
- import { t as plugin } from "./plugin-DhJZVIbl.js";
2
+ import { n as ArgsValidationErrorKeys, r as isArgsValidationError, t as ArgsValidationError } from "./resolver-dsINFnU2.js";
3
+ import { i as isCommandNotFoundError, n as CommandNotFoundErrorKeys, r as hasPriorityValidationError, t as CommandNotFoundError } from "./error-CBijJN5L.js";
4
+ import { t as plugin } from "./plugin-Cvf6mYto.js";
5
5
  export { ANONYMOUS_COMMAND_NAME, ArgsValidationError, ArgsValidationErrorKeys, CLI_OPTIONS_DEFAULT, CommandNotFoundError, CommandNotFoundErrorKeys, createCommandContext, hasPriorityValidationError, isArgsValidationError, isCommandNotFoundError, plugin };
package/lib/renderer.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as CommandContext, m as DefaultGunshiParams, y as GunshiParams } from "./types-CD5eRJFK.js";
1
+ import { a as CommandContext, m as DefaultGunshiParams, y as GunshiParams } from "./types-CdM9C6VD.js";
2
2
 
3
3
  //#region ../plugin-renderer/src/header.d.ts
4
4
  /**
package/lib/renderer.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as renderHeader, n as renderValidationErrors, r as renderUsage } from "./src-DIz-QFuo.js";
1
+ import { i as renderHeader, n as renderValidationErrors, r as renderUsage } from "./src-yiBqxwCm.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.28.0/node_modules/args-tokens/lib/parser-DT7Ztcch.d.ts
1
+ //#region ../../node_modules/.pnpm/args-tokens@0.28.2/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,7 +88,7 @@ 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.28.0/node_modules/args-tokens/lib/resolver.d.ts
91
+ //#region ../../node_modules/.pnpm/args-tokens@0.28.2/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.
@@ -548,12 +548,12 @@ interface ArgSchema {
548
548
  * i18n resource key for localized rendering.
549
549
  */
550
550
  declare const ArgsValidationErrorKeys: {
551
- readonly requiredOption: "err:arg:required-option";
552
- readonly requiredPositional: "err:arg:required-positional";
553
- readonly invalidType: "err:arg:invalid-type";
554
- readonly invalidChoice: "err:arg:invalid-choice";
555
- readonly customParse: "err:arg:custom-parse";
556
- readonly unknownOption: "err:arg:unknown-option";
551
+ readonly requiredOption: 'err:arg:required-option';
552
+ readonly requiredPositional: 'err:arg:required-positional';
553
+ readonly invalidType: 'err:arg:invalid-type';
554
+ readonly invalidChoice: 'err:arg:invalid-choice';
555
+ readonly customParse: 'err:arg:custom-parse';
556
+ readonly unknownOption: 'err:arg:unknown-option';
557
557
  };
558
558
  /**
559
559
  * A machine-readable argument validation error code.
@@ -632,7 +632,7 @@ type ResolveOptionValue<A extends ArgSchema, T> = A['multiple'] extends true ? T
632
632
  *
633
633
  * @internal
634
634
  */
635
- type ResolveArgValues<A extends Args, V extends Record<keyof A, unknown>> = { -readonly [Arg in keyof A]?: V[Arg] } & FilterArgs<A, V, 'default'> & FilterArgs<A, V, 'required'> & FilterPositionalArgs<A, V> extends infer P ? { [K in keyof P]: P[K] } : never;
635
+ type ResolveArgValues<A extends Args, V extends Record<keyof A, unknown>> = { -readonly [Arg in keyof A]?: V[Arg] } & FilterArgs<A, V, 'default'> & FilterArgs<A, V, 'required'> & FilterPositionalArgs<A, V> extends (infer P) ? { [K in keyof P]: P[K] } : never;
636
636
  /**
637
637
  * Filters the arguments based on their default values.
638
638
  *
@@ -1,5 +1,5 @@
1
- import { n as kebabnize, t as formatChoices } from "./utils-BKhsrjPW.js";
2
- //#region ../../node_modules/.pnpm/args-tokens@0.28.0/node_modules/args-tokens/lib/parser.js
1
+ import { n as kebabnize, t as formatChoices } from "./utils-oPJNnmOb.js";
2
+ //#region ../../node_modules/.pnpm/args-tokens@0.28.2/node_modules/args-tokens/lib/parser.js
3
3
  /**
4
4
  * forked from `nodejs/node` (`pkgjs/parseargs`)
5
5
  * repository url: https://github.com/nodejs/node (https://github.com/pkgjs/parseargs)
@@ -204,7 +204,7 @@ function hasOptionValue(value) {
204
204
  return !(value == null) && value.codePointAt(0) !== HYPHEN_CODE;
205
205
  }
206
206
  //#endregion
207
- //#region ../../node_modules/.pnpm/args-tokens@0.28.0/node_modules/args-tokens/lib/resolver.js
207
+ //#region ../../node_modules/.pnpm/args-tokens@0.28.2/node_modules/args-tokens/lib/resolver.js
208
208
  /**
209
209
  * Entry point of argument options resolver.
210
210
  *
@@ -306,9 +306,17 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
306
306
  const rest = [];
307
307
  const optionTokens = [];
308
308
  const positionalTokens = [];
309
+ const argEntries = Object.entries(args);
309
310
  let currentLongOption;
310
311
  let currentShortOption;
311
312
  const expandableShortOptions = [];
313
+ function getOptionName(rawArg, schema) {
314
+ return toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
315
+ }
316
+ function checkLongTokenName(option, schema, token) {
317
+ if (token.rawName == void 0 || !hasLongOptionPrefix(token.rawName)) return false;
318
+ return token.name === option || schema.type === "boolean" && schema.negatable === true && token.name === `no-${option}`;
319
+ }
312
320
  function toShortValue() {
313
321
  if (expandableShortOptions.length === 0) return;
314
322
  else {
@@ -336,6 +344,13 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
336
344
  * separate tokens into positionals, long and short options, after that resolve values
337
345
  */
338
346
  const schemas = Object.values(args);
347
+ const booleanLongOptionNames = /* @__PURE__ */ new Set();
348
+ for (const [rawArg, schema] of Object.entries(args)) {
349
+ if (schema.type !== "boolean") continue;
350
+ const arg = toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
351
+ booleanLongOptionNames.add(arg);
352
+ if (schema.negatable === true) booleanLongOptionNames.add(`no-${arg}`);
353
+ }
339
354
  let terminated = false;
340
355
  for (let i = 0; i < tokens.length; i++) {
341
356
  const token = tokens[i];
@@ -344,46 +359,52 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
344
359
  rest.push(token.value);
345
360
  continue;
346
361
  }
347
- if (currentShortOption) if (schemas.find((schema) => schema.short === currentShortOption.name && schema.type === "boolean")) {
348
- positionalTokens.push({ ...token });
349
- applyShortOptionValue();
350
- } else applyShortOptionValue(token.value);
351
- else if (currentLongOption) if (args[currentLongOption.name]?.type === "boolean") {
352
- positionalTokens.push({ ...token });
353
- applyLongOptionValue();
354
- } else applyLongOptionValue(token.value);
355
- else positionalTokens.push({ ...token });
356
- } else if (token.kind === "option") if (token.rawName) {
357
- if (hasLongOptionPrefix(token.rawName)) {
358
- applyLongOptionValue();
359
- if (token.inlineValue) optionTokens.push({ ...token });
360
- else currentLongOption = { ...token };
361
- applyShortOptionValue();
362
- } else if (isShortOption(token.rawName)) if (currentShortOption) {
363
- if (currentShortOption.index === token.index) if (shortGrouping) {
362
+ if (currentShortOption) {
363
+ if (schemas.find((schema) => schema.short === currentShortOption.name && schema.type === "boolean")) {
364
+ positionalTokens.push({ ...token });
365
+ applyShortOptionValue();
366
+ } else applyShortOptionValue(token.value);
367
+ } else if (currentLongOption) {
368
+ if (booleanLongOptionNames.has(currentLongOption.name)) {
369
+ positionalTokens.push({ ...token });
370
+ applyLongOptionValue();
371
+ } else applyLongOptionValue(token.value);
372
+ } else positionalTokens.push({ ...token });
373
+ } else if (token.kind === "option") {
374
+ if (token.rawName) {
375
+ if (hasLongOptionPrefix(token.rawName)) {
376
+ applyLongOptionValue();
377
+ if (token.inlineValue) optionTokens.push({ ...token });
378
+ else currentLongOption = { ...token };
379
+ applyShortOptionValue();
380
+ } else if (isShortOption(token.rawName)) {
381
+ if (currentShortOption) {
382
+ if (currentShortOption.index === token.index) {
383
+ if (shortGrouping) {
384
+ currentShortOption.value = token.value;
385
+ optionTokens.push({ ...currentShortOption });
386
+ currentShortOption = { ...token };
387
+ } else expandableShortOptions.push({ ...token });
388
+ } else {
389
+ currentShortOption.value = toShortValue();
390
+ optionTokens.push({ ...currentShortOption });
391
+ currentShortOption = { ...token };
392
+ }
393
+ applyLongOptionValue();
394
+ } else {
395
+ currentShortOption = { ...token };
396
+ applyLongOptionValue();
397
+ }
398
+ }
399
+ } else {
400
+ if (currentShortOption && currentShortOption.index == token.index && token.inlineValue) {
364
401
  currentShortOption.value = token.value;
365
402
  optionTokens.push({ ...currentShortOption });
366
- currentShortOption = { ...token };
367
- } else expandableShortOptions.push({ ...token });
368
- else {
369
- currentShortOption.value = toShortValue();
370
- optionTokens.push({ ...currentShortOption });
371
- currentShortOption = { ...token };
403
+ currentShortOption = void 0;
372
404
  }
373
405
  applyLongOptionValue();
374
- } else {
375
- currentShortOption = { ...token };
376
- applyLongOptionValue();
377
406
  }
378
407
  } else {
379
- if (currentShortOption && currentShortOption.index == token.index && token.inlineValue) {
380
- currentShortOption.value = token.value;
381
- optionTokens.push({ ...currentShortOption });
382
- currentShortOption = void 0;
383
- }
384
- applyLongOptionValue();
385
- }
386
- else {
387
408
  if (token.kind === "option-terminator") terminated = true;
388
409
  applyLongOptionValue();
389
410
  applyShortOptionValue();
@@ -401,11 +422,7 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
401
422
  const errors = [];
402
423
  const explicit = Object.create(null);
403
424
  const actualInputNames = /* @__PURE__ */ new Map();
404
- const argEntries = Object.entries(args);
405
425
  let requiredPositionalsAfter;
406
- function checkTokenName(option, schema, token) {
407
- return token.name === (schema.type === "boolean" ? schema.negatable && token.name?.startsWith("no-") ? `no-${option}` : option : option);
408
- }
409
426
  const positionalItemCount = tokens.filter((token) => token.kind === "positional").length;
410
427
  function getPositionalSkipIndex() {
411
428
  return Math.min(skipPositionalIndex, positionalItemCount);
@@ -416,7 +433,7 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
416
433
  }
417
434
  let positionalsCount = 0;
418
435
  for (const [rawArg, schema] of argEntries) {
419
- const arg = toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
436
+ const arg = getOptionName(rawArg, schema);
420
437
  explicit[rawArg] = false;
421
438
  if (schema.type === "positional") {
422
439
  if (skipPositionalIndex > SKIP_POSITIONAL_DEFAULT) while (positionalsCount <= getPositionalSkipIndex()) positionalsCount++;
@@ -470,7 +487,7 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
470
487
  }
471
488
  if (schema.required) {
472
489
  if (!optionTokens.find((token) => {
473
- return schema.short && token.name === schema.short || token.rawName && hasLongOptionPrefix(token.rawName) && token.name === arg;
490
+ return schema.short && token.name === schema.short && token.rawName != void 0 && isShortOption(token.rawName) || checkLongTokenName(arg, schema, token);
474
491
  })) {
475
492
  errors.push(createRequireError(rawArg, arg, schema));
476
493
  continue;
@@ -478,14 +495,15 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
478
495
  }
479
496
  for (let i = 0; i < optionTokens.length; i++) {
480
497
  const token = optionTokens[i];
481
- if (checkTokenName(arg, schema, token) && token.rawName != void 0 && hasLongOptionPrefix(token.rawName) || schema.short === token.name && token.rawName != void 0 && isShortOption(token.rawName)) {
498
+ if (checkLongTokenName(arg, schema, token) || schema.short === token.name && token.rawName != void 0 && isShortOption(token.rawName)) {
482
499
  const invalid = validateRequire(token, rawArg, arg, schema);
483
500
  if (invalid) {
484
501
  errors.push(invalid);
485
502
  continue;
486
503
  }
487
504
  explicit[rawArg] = true;
488
- const actualInputName = isShortOption(token.rawName) ? `-${token.name}` : `--${arg}`;
505
+ const rawName = token.rawName;
506
+ const actualInputName = isShortOption(rawName) ? `-${token.name}` : rawName;
489
507
  actualInputNames.set(rawArg, actualInputName);
490
508
  const [parsedValue, error] = parse(token, rawArg, arg, schema);
491
509
  if (error) errors.push(error);
@@ -1,9 +1,9 @@
1
1
  import "./context-CAPhwgJJ.js";
2
- import { n as kebabnize } from "./utils-BKhsrjPW.js";
2
+ import { n as kebabnize } from "./utils-oPJNnmOb.js";
3
3
  import { resolveLazyCommand } from "./utils.js";
4
- import { n as ArgsValidationErrorKeys, r as isArgsValidationError } from "./resolver-UFOtObbe.js";
5
- import { i as isCommandNotFoundError } from "./error-xSnOOdnr.js";
6
- import { t as plugin } from "./plugin-DhJZVIbl.js";
4
+ import { n as ArgsValidationErrorKeys, r as isArgsValidationError } from "./resolver-dsINFnU2.js";
5
+ import { i as isCommandNotFoundError } from "./error-CBijJN5L.js";
6
+ import { t as plugin } from "./plugin-Cvf6mYto.js";
7
7
  /**
8
8
  * @author kazuya kawaguchi (a.k.a. kazupon)
9
9
  * @license MIT
@@ -315,9 +315,10 @@ async function renderUsageSection(ctx) {
315
315
  }
316
316
  async function makeUsageSymbols(ctx) {
317
317
  const messages = [await resolveEntry(ctx)];
318
- if (ctx.omitted) if (await hasCommands(ctx)) messages.push(` [${await ctx.extensions[pluginId].text(resolveBuiltInKey("COMMANDS"))}]`);
319
- else messages.push(`${ctx.callMode === "subCommand" ? ` ${await resolveSubCommand(ctx)}` : ""}`);
320
- else messages.push(`${ctx.callMode === "subCommand" ? ` ${await resolveSubCommand(ctx)}` : ""}`);
318
+ if (ctx.omitted) {
319
+ if (await hasCommands(ctx)) messages.push(` [${await ctx.extensions[pluginId].text(resolveBuiltInKey("COMMANDS"))}]`);
320
+ else messages.push(`${ctx.callMode === "subCommand" ? ` ${await resolveSubCommand(ctx)}` : ""}`);
321
+ } else messages.push(`${ctx.callMode === "subCommand" ? ` ${await resolveSubCommand(ctx)}` : ""}`);
321
322
  const optionsSymbols = await generateOptionsSymbols(ctx, ctx.args);
322
323
  if (optionsSymbols) messages.push(" ", optionsSymbols);
323
324
  const positionalSymbols = generatePositionalSymbols(ctx.args);
@@ -1,4 +1,4 @@
1
- import { i as Args, n as ArgSchema, r as ArgValues, t as ArgExplicitlyProvided, u as ArgToken } from "./resolver-CgkhQ6Tt.js";
1
+ import { i as Args, n as ArgSchema, r as ArgValues, t as ArgExplicitlyProvided, u as ArgToken } from "./resolver-D7DEcpu-.js";
2
2
 
3
3
  //#region src/plugin/context.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/args-tokens@0.28.0/node_modules/args-tokens/lib/utils.js
1
+ //#region ../../node_modules/.pnpm/args-tokens@0.28.2/node_modules/args-tokens/lib/utils.js
2
2
  /**
3
3
  * Entry point of utils.
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-CD5eRJFK.js";
1
+ import { b as GunshiParamsConstraint, m as DefaultGunshiParams, p as Commandable, r as Command, x as LazyCommand } from "./types-CdM9C6VD.js";
2
2
 
3
- //#region ../../node_modules/.pnpm/args-tokens@0.28.0/node_modules/args-tokens/lib/utils.d.ts
3
+ //#region ../../node_modules/.pnpm/args-tokens@0.28.2/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,4 +1,4 @@
1
- import { n as kebabnize } from "./utils-BKhsrjPW.js";
1
+ import { n as kebabnize } from "./utils-oPJNnmOb.js";
2
2
  //#region src/utils.ts
3
3
  /**
4
4
  * @author kazuya kawaguchi (a.k.a. kazupon)
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.37.0",
4
+ "version": "0.37.2",
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.28.0",
111
+ "args-tokens": "^0.28.2",
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-global": "0.37.0",
120
- "@gunshi/resources": "0.37.0",
121
- "@gunshi/plugin-i18n": "0.37.0",
122
- "@gunshi/plugin-renderer": "0.37.0",
123
- "@gunshi/shared": "0.37.0"
119
+ "@gunshi/plugin-i18n": "0.37.2",
120
+ "@gunshi/plugin-global": "0.37.2",
121
+ "@gunshi/resources": "0.37.2",
122
+ "@gunshi/plugin-renderer": "0.37.2",
123
+ "@gunshi/shared": "0.37.2"
124
124
  },
125
125
  "scripts": {
126
126
  "build": "tsdown",