gunshi 0.27.3 → 0.27.5

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,4 @@
1
- import { A as SubCommandable, C as GunshiParams, D as Prettify, E as NormalizeToGunshiParams, O as RendererDecorator, S as ExtractExtensions, T as LazyCommand, _ as Commandable, a as Awaitable, b as ExtractArgExplicitlyProvided, c as CommandCallMode, d as CommandContextExtension, f as CommandDecorator, g as CommandRunner, h as CommandLoader, i as Args, j as ValidationErrorsDecorator, k as RenderingOptions, l as CommandContext, m as CommandExamplesFetcher, n as ArgToken, o as CliOptions, p as CommandEnvironment, r as ArgValues, s as Command, t as ArgSchema, u as CommandContextCore, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext } from "./types-n4yrH5jq.js";
1
+ import { A as SubCommandable, C as GunshiParams, D as Prettify, E as NormalizeToGunshiParams, O as RendererDecorator, S as ExtractExtensions, T as LazyCommand, _ as Commandable, a as Awaitable, b as ExtractArgExplicitlyProvided, c as CommandCallMode, d as CommandContextExtension, f as CommandDecorator, g as CommandRunner, h as CommandLoader, i as Args, j as ValidationErrorsDecorator, k as RenderingOptions, l as CommandContext, m as CommandExamplesFetcher, n as ArgToken, o as CliOptions, p as CommandEnvironment, r as ArgValues, s as Command, t as ArgSchema, u as CommandContextCore, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext } from "./types-Bh6G4DvQ.js";
2
2
 
3
3
  //#region src/cli/bone.d.ts
4
4
  /**
@@ -1,6 +1,6 @@
1
1
  import { t as cliCore } from "./core-D15eimMG.js";
2
- import { t as plugin } from "./plugin-bQlPfOlH.js";
3
- import { a as namespacedId, s as COMMON_ARGS, t as renderer } from "./src-CY4_1ike.js";
2
+ import { t as plugin } from "./plugin-vBhmK2n3.js";
3
+ import { a as namespacedId, s as COMMON_ARGS, t as renderer } from "./src-BXKp6yTi.js";
4
4
 
5
5
  //#region ../plugin-global/src/types.ts
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { C as GunshiParams, T as LazyCommand, b as ExtractArgExplicitlyProvided, c as CommandCallMode, d as CommandContextExtension, i as Args, l as CommandContext, n as ArgToken, o as CliOptions, r as ArgValues, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext } from "./types-n4yrH5jq.js";
1
+ import { C as GunshiParams, T as LazyCommand, b as ExtractArgExplicitlyProvided, c as CommandCallMode, d as CommandContextExtension, i as Args, l as CommandContext, n as ArgToken, o as CliOptions, r as ArgValues, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext } from "./types-Bh6G4DvQ.js";
2
2
 
3
3
  //#region src/context.d.ts
4
4
 
package/lib/context.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import "./types-n4yrH5jq.js";
2
- import { n as ExtractExtensions, r as createCommandContext, t as CommandContextParams } from "./context-Pe5vk9kJ.js";
1
+ import "./types-Bh6G4DvQ.js";
2
+ import { n as ExtractExtensions, r as createCommandContext, t as CommandContextParams } from "./context-DZzjf_Et.js";
3
3
  export { CommandContextParams, ExtractExtensions, createCommandContext };
@@ -1,4 +1,4 @@
1
- import { C as GunshiParams, D as Prettify, S as ExtractExtensions, T as LazyCommand, h as CommandLoader, i as Args, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext } from "./types-n4yrH5jq.js";
1
+ import { C as GunshiParams, D as Prettify, S as ExtractExtensions, T as LazyCommand, h as CommandLoader, i as Args, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext } from "./types-Bh6G4DvQ.js";
2
2
 
3
3
  //#region src/definition.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { C as GunshiParams, T as LazyCommand, g as CommandRunner, h as CommandLoader, i as Args, r as ArgValues, s as Command, t as ArgSchema, v as DefaultGunshiParams, y as ExtendContext } from "./types-n4yrH5jq.js";
2
- import { r as createCommandContext, t as CommandContextParams } from "./context-Pe5vk9kJ.js";
3
- import { i as lazyWithTypes, n as defineWithTypes, r as lazy, t as define } from "./definition-BNViywAg.js";
1
+ import { C as GunshiParams, T as LazyCommand, g as CommandRunner, h as CommandLoader, i as Args, r as ArgValues, s as Command, t as ArgSchema, v as DefaultGunshiParams, y as ExtendContext } from "./types-Bh6G4DvQ.js";
2
+ import { r as createCommandContext, t as CommandContextParams } from "./context-DZzjf_Et.js";
3
+ import { i as lazyWithTypes, n as defineWithTypes, r as lazy, t as define } from "./definition-DhDR8aNJ.js";
4
4
  export { ArgSchema, ArgValues, Args, Command, CommandContextParams, CommandLoader, CommandRunner, DefaultGunshiParams, ExtendContext, GunshiParams, LazyCommand, createCommandContext, define, defineWithTypes, lazy, lazyWithTypes };
package/lib/definition.js CHANGED
@@ -1,5 +1,112 @@
1
1
  import { t as createCommandContext } from "./context-DRQZ3doU.js";
2
2
  import "./utils-DA31tfdY.js";
3
- import { i as lazyWithTypes, n as defineWithTypes, r as lazy, t as define } from "./definition-D5821Sur.js";
4
3
 
4
+ //#region src/definition.ts
5
+ /**
6
+ * Define a {@link Command | command}.
7
+ *
8
+ * @typeParam G - A {@link GunshiParamsConstraint} type
9
+ *
10
+ * @param definition - A {@link Command | command} definition
11
+ * @returns A defined {@link Command | command}
12
+ */
13
+ function define(definition) {
14
+ return definition;
15
+ }
16
+ /**
17
+ * Define a {@link Command | command} with types
18
+ *
19
+ * This helper function allows specifying the type parameter of {@link GunshiParams}
20
+ * while inferring the {@link Args} type, {@link ExtendContext} type from the definition.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * // Define a command with specific extensions type
25
+ * type MyExtensions = { logger: { log: (message: string) => void } }
26
+ *
27
+ * const command = defineWithTypes<{ extensions: MyExtensions }>()({
28
+ * name: 'greet',
29
+ * args: {
30
+ * name: { type: 'string' }
31
+ * },
32
+ * run: ctx => {
33
+ * // ctx.values is inferred as { name?: string }
34
+ * // ctx.extensions is MyExtensions
35
+ * }
36
+ * })
37
+ * ```
38
+ *
39
+ * @typeParam G - A {@link GunshiParams} type
40
+ *
41
+ * @returns A function that takes a command definition via {@link define}
42
+ *
43
+ * @since v0.27.0
44
+ */
45
+ function defineWithTypes() {
46
+ return (definition) => {
47
+ return define(definition);
48
+ };
49
+ }
50
+ /**
51
+ * Define a {@link LazyCommand | lazy command} with or without definition.
52
+ *
53
+ * @param loader - A {@link CommandLoader | command loader} function that returns a command definition
54
+ * @param definition - An optional {@link Command | command} definition
55
+ * @returns A {@link LazyCommand | lazy command} that can be executed later
56
+ */
57
+ function lazy(loader, definition) {
58
+ const lazyCommand = loader;
59
+ if (definition != null) {
60
+ lazyCommand.commandName = definition.name;
61
+ lazyCommand.description = definition.description;
62
+ lazyCommand.args = definition.args;
63
+ lazyCommand.examples = definition.examples;
64
+ lazyCommand.internal = definition.internal;
65
+ lazyCommand.entry = definition.entry;
66
+ lazyCommand.toKebab = definition.toKebab;
67
+ if ("resource" in definition) lazyCommand.resource = definition.resource;
68
+ }
69
+ return lazyCommand;
70
+ }
71
+ /**
72
+ * Define a {@link LazyCommand | lazy command} with specific type parameters.
73
+ *
74
+ * This helper function allows specifying the type parameter of {@link GunshiParams}
75
+ * while inferring the {@link Args} type, {@link ExtendContext} type from the definition.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * type MyExtensions = { logger: { log: (message: string) => void } }
80
+ *
81
+ * const command = lazyWithTypes<{ extensions: MyExtensions }>()(
82
+ * () => {
83
+ * return ctx => {
84
+ * // Command runner implementation
85
+ * ctx.extensions.logger?.log('Command executed')
86
+ * },
87
+ * {
88
+ * name: 'lazy-command',
89
+ * args: {
90
+ * opt: {
91
+ * type: 'string',
92
+ * description: 'An optional string argument',
93
+ * required: false,
94
+ * },
95
+ * },
96
+ * )
97
+ * ```
98
+ *
99
+ * @typeParam G - A {@link GunshiParams} type
100
+ *
101
+ * @returns A function that takes a lazy command definition via {@link lazy}
102
+ *
103
+ * @since v0.27.0
104
+ */
105
+ function lazyWithTypes() {
106
+ return (loader, definition) => {
107
+ return lazy(loader, definition);
108
+ };
109
+ }
110
+
111
+ //#endregion
5
112
  export { createCommandContext, define, defineWithTypes, lazy, lazyWithTypes };
@@ -1,4 +1,4 @@
1
- import { T as LazyCommand, o as CliOptions, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint } from "./types-n4yrH5jq.js";
1
+ import { T as LazyCommand, o as CliOptions, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint } from "./types-Bh6G4DvQ.js";
2
2
 
3
3
  //#region src/generator.d.ts
4
4
 
package/lib/generator.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import "./context-DRQZ3doU.js";
2
2
  import { t as create } from "./utils-DA31tfdY.js";
3
3
  import "./core-D15eimMG.js";
4
- import "./plugin-bQlPfOlH.js";
5
- import "./src-CY4_1ike.js";
6
- import { t as cli } from "./cli-CvbMnupQ.js";
4
+ import "./plugin-vBhmK2n3.js";
5
+ import "./src-BXKp6yTi.js";
6
+ import { t as cli } from "./cli-BtnhCdFu.js";
7
7
 
8
8
  //#region src/generator.ts
9
9
  /**
@@ -1,4 +1,4 @@
1
- import { A as SubCommandable, C as GunshiParams, T as LazyCommand, g as CommandRunner, i as Args$1, o as CliOptions, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint, y as ExtendContext } from "./types-n4yrH5jq.js";
1
+ import { A as SubCommandable, C as GunshiParams, T as LazyCommand, g as CommandRunner, i as Args$1, o as CliOptions, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint, y as ExtendContext } from "./types-Bh6G4DvQ.js";
2
2
  import { parseArgs as parseArgs$1, resolveArgs as resolveArgs$1 } from "args-tokens";
3
3
 
4
4
  //#region ../plugin-i18n/src/types.d.ts
@@ -104,18 +104,6 @@ declare class DefaultTranslation implements TranslationAdapter {
104
104
  }
105
105
  //#endregion
106
106
  //#region src/cli/builtin.d.ts
107
- /**
108
- * Run the command.
109
- *
110
- * This overload accepts any command-like object using a loose structural type.
111
- * It bypasses TypeScript contravariance issues with callback properties.
112
- *
113
- * @param args - Command line arguments
114
- * @param entry - A command-like object (command, command runner, or lazy command)
115
- * @param options - A {@link CliOptions | CLI options}
116
- * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
117
- */
118
- declare function cli(args: string[], entry: SubCommandable, options?: CliOptions): Promise<string | undefined>;
119
107
  /**
120
108
  * Run the command.
121
109
  *
@@ -166,5 +154,22 @@ declare function cli<E extends ExtendContext = ExtendContext, G extends GunshiPa
166
154
  * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
167
155
  */
168
156
  declare function cli<G extends GunshiParams = DefaultGunshiParams>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
157
+ /**
158
+ * Run the command.
159
+ *
160
+ * This overload accepts any command-like object using a loose structural type.
161
+ * It bypasses TypeScript contravariance issues with callback properties.
162
+ *
163
+ * Note: This overload MUST be last in the overload list. TypeScript checks overloads
164
+ * in declaration order and selects the first matching one. The SubCommandable type
165
+ * is intentionally loose and would match any command, so placing it first would
166
+ * prevent proper type inference for more specific command types.
167
+ *
168
+ * @param args - Command line arguments
169
+ * @param entry - A command-like object (command, command runner, or lazy command)
170
+ * @param options - A {@link CliOptions | CLI options}
171
+ * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
172
+ */
173
+ declare function cli(args: string[], entry: SubCommandable, options?: CliOptions): Promise<string | undefined>;
169
174
  //#endregion
170
175
  export { DefaultTranslation as i, resolveArgs$1 as n, cli as r, parseArgs$1 as t };
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { A as SubCommandable, B as plugin, C as GunshiParams, D as Prettify, E as NormalizeToGunshiParams, F as PluginExtension, I as PluginFunction, L as PluginOptions, M as OnPluginExtension, N as Plugin, O as RendererDecorator, P as PluginDependency, R as PluginWithExtension, S as ExtractExtensions, T as LazyCommand, V as PluginContext, _ as Commandable, a as Awaitable, b as ExtractArgExplicitlyProvided, c as CommandCallMode, d as CommandContextExtension, f as CommandDecorator, g as CommandRunner, h as CommandLoader, i as Args, j as ValidationErrorsDecorator, k as RenderingOptions, l as CommandContext, m as CommandExamplesFetcher, n as ArgToken, o as CliOptions, p as CommandEnvironment, r as ArgValues, s as Command, t as ArgSchema, u as CommandContextCore, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext, z as PluginWithoutExtension } from "./types-n4yrH5jq.js";
2
- import { r as createCommandContext, t as CommandContextParams } from "./context-Pe5vk9kJ.js";
3
- import { i as lazyWithTypes, n as defineWithTypes, r as lazy, t as define } from "./definition-BNViywAg.js";
4
- import { t as ANONYMOUS_COMMAND_NAME } from "./plugin-aAXfXUT6.js";
5
- import { i as DefaultTranslation, n as resolveArgs, r as cli, t as parseArgs } from "./index-CCtD9wBS.js";
6
- import "./utils-BV37YoO0.js";
1
+ import { A as SubCommandable, B as plugin, C as GunshiParams, D as Prettify, E as NormalizeToGunshiParams, F as PluginExtension, I as PluginFunction, L as PluginOptions, M as OnPluginExtension, N as Plugin, O as RendererDecorator, P as PluginDependency, R as PluginWithExtension, S as ExtractExtensions, T as LazyCommand, V as PluginContext, _ as Commandable, a as Awaitable, b as ExtractArgExplicitlyProvided, c as CommandCallMode, d as CommandContextExtension, f as CommandDecorator, g as CommandRunner, h as CommandLoader, i as Args, j as ValidationErrorsDecorator, k as RenderingOptions, l as CommandContext, m as CommandExamplesFetcher, n as ArgToken, o as CliOptions, p as CommandEnvironment, r as ArgValues, s as Command, t as ArgSchema, u as CommandContextCore, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext, z as PluginWithoutExtension } from "./types-Bh6G4DvQ.js";
2
+ import { r as createCommandContext, t as CommandContextParams } from "./context-DZzjf_Et.js";
3
+ import { i as lazyWithTypes, n as defineWithTypes, r as lazy, t as define } from "./definition-DhDR8aNJ.js";
4
+ import { t as ANONYMOUS_COMMAND_NAME } from "./plugin-DvvZ2zsE.js";
5
+ import { i as DefaultTranslation, n as resolveArgs, r as cli, t as parseArgs } from "./index-DuyhzAeh.js";
6
+ import "./utils-DPF_9WLN.js";
7
7
  export { ANONYMOUS_COMMAND_NAME, ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, CommandContextParams, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, DefaultTranslation, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, OnPluginExtension, Plugin, PluginContext, PluginDependency, PluginExtension, PluginFunction, PluginOptions, PluginWithExtension, PluginWithoutExtension, Prettify, RendererDecorator, RenderingOptions, SubCommandable, ValidationErrorsDecorator, cli, createCommandContext, define, defineWithTypes, lazy, lazyWithTypes, parseArgs, plugin, resolveArgs };
package/lib/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { n as ANONYMOUS_COMMAND_NAME, t as createCommandContext } from "./context-DRQZ3doU.js";
2
2
  import "./utils-DA31tfdY.js";
3
3
  import "./core-D15eimMG.js";
4
- import { i as lazyWithTypes, n as defineWithTypes, r as lazy, t as define } from "./definition-D5821Sur.js";
5
- import { t as plugin } from "./plugin-bQlPfOlH.js";
6
- import { a as namespacedId, o as BUILT_IN_PREFIX } from "./src-CY4_1ike.js";
7
- import { t as cli } from "./cli-CvbMnupQ.js";
4
+ import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition.js";
5
+ import { t as plugin } from "./plugin-vBhmK2n3.js";
6
+ import { a as namespacedId, o as BUILT_IN_PREFIX } from "./src-BXKp6yTi.js";
7
+ import { t as cli } from "./cli-BtnhCdFu.js";
8
8
  import { parseArgs, resolveArgs } from "args-tokens";
9
9
 
10
10
  //#region ../plugin-i18n/src/translation.ts
@@ -66,7 +66,7 @@ var DefaultTranslation = class {
66
66
  if (message === void 0 && locale !== this.#options.fallbackLocale) message = this.getMessage(this.#options.fallbackLocale, key);
67
67
  if (message === void 0) return;
68
68
  return message.replaceAll(/\{\$(\w+)\}/g, (_, name) => {
69
- return values[name] == null ? "" : values[name].toString();
69
+ return values[name] == null ? "" : values[name];
70
70
  });
71
71
  }
72
72
  };
@@ -1,4 +1,4 @@
1
- import { o as CliOptions, v as DefaultGunshiParams } from "./types-n4yrH5jq.js";
1
+ import { o as CliOptions, v as DefaultGunshiParams } from "./types-Bh6G4DvQ.js";
2
2
 
3
3
  //#region src/constants.d.ts
4
4
  /**
package/lib/plugin.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { B as plugin, C as GunshiParams, D as Prettify, E as NormalizeToGunshiParams, F as PluginExtension, I as PluginFunction, L as PluginOptions, M as OnPluginExtension, N as Plugin, O as RendererDecorator, P as PluginDependency, R as PluginWithExtension, S as ExtractExtensions, T as LazyCommand, V as PluginContext, a as Awaitable, d as CommandContextExtension, f as CommandDecorator, g as CommandRunner, i as Args, j as ValidationErrorsDecorator, l as CommandContext, m as CommandExamplesFetcher, n as ArgToken, r as ArgValues, s as Command, t as ArgSchema, u as CommandContextCore, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext, z as PluginWithoutExtension } from "./types-n4yrH5jq.js";
2
- import { r as createCommandContext, t as CommandContextParams } from "./context-Pe5vk9kJ.js";
3
- import { n as CLI_OPTIONS_DEFAULT, t as ANONYMOUS_COMMAND_NAME } from "./plugin-aAXfXUT6.js";
1
+ import { B as plugin, C as GunshiParams, D as Prettify, E as NormalizeToGunshiParams, F as PluginExtension, I as PluginFunction, L as PluginOptions, M as OnPluginExtension, N as Plugin, O as RendererDecorator, P as PluginDependency, R as PluginWithExtension, S as ExtractExtensions, T as LazyCommand, V as PluginContext, a as Awaitable, d as CommandContextExtension, f as CommandDecorator, g as CommandRunner, i as Args, j as ValidationErrorsDecorator, l as CommandContext, m as CommandExamplesFetcher, n as ArgToken, r as ArgValues, s as Command, t as ArgSchema, u as CommandContextCore, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext, z as PluginWithoutExtension } from "./types-Bh6G4DvQ.js";
2
+ import { r as createCommandContext, t as CommandContextParams } from "./context-DZzjf_Et.js";
3
+ import { n as CLI_OPTIONS_DEFAULT, t as ANONYMOUS_COMMAND_NAME } from "./plugin-DvvZ2zsE.js";
4
4
  export { ANONYMOUS_COMMAND_NAME, ArgSchema, ArgToken, ArgValues, Args, Awaitable, CLI_OPTIONS_DEFAULT, Command, CommandContext, CommandContextCore, CommandContextExtension, CommandContextParams, CommandDecorator, CommandExamplesFetcher, CommandRunner, DefaultGunshiParams, ExtendContext, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, OnPluginExtension, Plugin, PluginContext, PluginDependency, PluginExtension, PluginFunction, PluginOptions, PluginWithExtension, PluginWithoutExtension, Prettify, RendererDecorator, ValidationErrorsDecorator, createCommandContext, plugin };
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-DRQZ3doU.js";
2
2
  import "./utils-DA31tfdY.js";
3
- import { t as plugin } from "./plugin-bQlPfOlH.js";
3
+ import { t as plugin } from "./plugin-vBhmK2n3.js";
4
4
 
5
5
  export { ANONYMOUS_COMMAND_NAME, CLI_OPTIONS_DEFAULT, createCommandContext, plugin };
package/lib/renderer.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { C as GunshiParams, l as CommandContext, v as DefaultGunshiParams } from "./types-n4yrH5jq.js";
2
- import "./context-Pe5vk9kJ.js";
3
- import "./definition-BNViywAg.js";
4
- import "./plugin-aAXfXUT6.js";
5
- import "./index-CCtD9wBS.js";
6
- import "./utils-BV37YoO0.js";
1
+ import { C as GunshiParams, l as CommandContext, v as DefaultGunshiParams } from "./types-Bh6G4DvQ.js";
2
+ import "./context-DZzjf_Et.js";
3
+ import "./definition-DhDR8aNJ.js";
4
+ import "./plugin-DvvZ2zsE.js";
5
+ import "./index-DuyhzAeh.js";
6
+ import "./utils-DPF_9WLN.js";
7
7
 
8
8
  //#region ../plugin-renderer/src/header.d.ts
9
9
  /**
package/lib/renderer.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./context-DRQZ3doU.js";
2
2
  import "./utils-DA31tfdY.js";
3
- import "./plugin-bQlPfOlH.js";
4
- import { i as renderHeader, n as renderValidationErrors, r as renderUsage } from "./src-CY4_1ike.js";
3
+ import "./plugin-vBhmK2n3.js";
4
+ import { i as renderHeader, n as renderValidationErrors, r as renderUsage } from "./src-BXKp6yTi.js";
5
5
 
6
6
  export { renderHeader, renderUsage, renderValidationErrors };
@@ -1,6 +1,6 @@
1
1
  import { n as ANONYMOUS_COMMAND_NAME } from "./context-DRQZ3doU.js";
2
2
  import { i as kebabnize, o as resolveLazyCommand } from "./utils-DA31tfdY.js";
3
- import { t as plugin } from "./plugin-bQlPfOlH.js";
3
+ import { t as plugin } from "./plugin-vBhmK2n3.js";
4
4
 
5
5
  //#region ../shared/src/constants.ts
6
6
  /**
@@ -895,27 +895,49 @@ type Commandable<G extends GunshiParamsConstraint = DefaultGunshiParams> = Comma
895
895
  * @since v0.27.1
896
896
  */
897
897
  interface SubCommandable {
898
- /** Command name */
898
+ /**
899
+ * see {@link Command.name}
900
+ */
899
901
  name?: string;
900
- /** Command description */
902
+ /**
903
+ * see {@link Command.description}
904
+ */
901
905
  description?: string;
902
- /** Command arguments - accepts any args structure */
906
+ /**
907
+ * see {@link Command.args}
908
+ */
903
909
  args?: Args | Record<string, any>;
904
- /** Command examples */
910
+ /**
911
+ * see {@link Command.examples}
912
+ */
905
913
  examples?: string | ((...args: any[]) => any);
906
- /** Command runner */
914
+ /**
915
+ * see {@link Command.run}
916
+ */
907
917
  run?: (...args: any[]) => any;
908
- /** Whether to convert camelCase to kebab-case */
918
+ /**
919
+ * see {@link Command.toKebab}
920
+ */
909
921
  toKebab?: boolean;
910
- /** Whether this is an internal command */
922
+ /**
923
+ * see {@link Command.internal}
924
+ */
911
925
  internal?: boolean;
912
- /** Whether this is an entry command */
926
+ /**
927
+ * see {@link Command.entry}
928
+ */
913
929
  entry?: boolean;
914
- /** Rendering options */
930
+ /**
931
+ * see {@link Command.rendering}
932
+ */
915
933
  rendering?: any;
916
- /** Command name for lazy commands */
934
+ /**
935
+ * see {@link LazyCommand.commandName}
936
+ */
917
937
  commandName?: string;
918
- /** Index signature to allow additional properties */
938
+ /**
939
+ * Index signature to allow additional properties
940
+ */
919
941
  [key: string]: any;
920
942
  }
921
943
  /**
@@ -1,4 +1,4 @@
1
- import { T as LazyCommand, _ as Commandable, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint } from "./types-n4yrH5jq.js";
1
+ import { T as LazyCommand, _ as Commandable, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint } from "./types-Bh6G4DvQ.js";
2
2
  import { kebabnize } from "args-tokens/utils";
3
3
 
4
4
  //#region src/utils.d.ts
@@ -43,8 +43,6 @@ declare function log(...args: unknown[]): void;
43
43
  * @param ignores - Properties to ignore during freezing
44
44
  * @returns A frozen object
45
45
  */
46
- declare function deepFreeze<T extends Record<string, any>>(
47
- // eslint-disable-line @typescript-eslint/no-explicit-any -- NOTE(kazupon): generic type for deepFreeze
48
- obj: T, ignores?: string[]): Readonly<T>;
46
+ declare function deepFreeze<T extends Record<string, any>>(obj: T, ignores?: string[]): Readonly<T>;
49
47
  //#endregion
50
48
  export { log as a, kebabnize as i, deepFreeze as n, resolveLazyCommand as o, isLazyCommand as r, create as t };
package/lib/utils.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import "./types-n4yrH5jq.js";
2
- import { a as log, i as kebabnize, n as deepFreeze, o as resolveLazyCommand, r as isLazyCommand, t as create } from "./utils-BV37YoO0.js";
1
+ import "./types-Bh6G4DvQ.js";
2
+ import { a as log, i as kebabnize, n as deepFreeze, o as resolveLazyCommand, r as isLazyCommand, t as create } from "./utils-DPF_9WLN.js";
3
3
  export { create, deepFreeze, 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.27.3",
4
+ "version": "0.27.5",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -99,17 +99,17 @@
99
99
  "args-tokens": "^0.23.0"
100
100
  },
101
101
  "devDependencies": {
102
- "deno": "^2.5.6",
102
+ "deno": "^2.6.3",
103
103
  "jsr": "^0.13.5",
104
104
  "jsr-exports-lint": "^0.4.1",
105
105
  "publint": "^0.3.16",
106
106
  "tsdown": "0.15.12",
107
107
  "zod": "^4.2.1",
108
- "@gunshi/plugin-global": "0.27.3",
109
- "@gunshi/plugin-renderer": "0.27.3",
110
- "@gunshi/resources": "0.27.3",
111
- "@gunshi/shared": "0.27.3",
112
- "@gunshi/plugin-i18n": "0.27.3"
108
+ "@gunshi/plugin-global": "0.27.5",
109
+ "@gunshi/plugin-renderer": "0.27.5",
110
+ "@gunshi/plugin-i18n": "0.27.5",
111
+ "@gunshi/shared": "0.27.5",
112
+ "@gunshi/resources": "0.27.5"
113
113
  },
114
114
  "scripts": {
115
115
  "build": "tsdown",
@@ -1,109 +0,0 @@
1
- //#region src/definition.ts
2
- /**
3
- * Define a {@link Command | command}.
4
- *
5
- * @typeParam G - A {@link GunshiParamsConstraint} type
6
- *
7
- * @param definition - A {@link Command | command} definition
8
- * @returns A defined {@link Command | command}
9
- */
10
- function define(definition) {
11
- return definition;
12
- }
13
- /**
14
- * Define a {@link Command | command} with types
15
- *
16
- * This helper function allows specifying the type parameter of {@link GunshiParams}
17
- * while inferring the {@link Args} type, {@link ExtendContext} type from the definition.
18
- *
19
- * @example
20
- * ```ts
21
- * // Define a command with specific extensions type
22
- * type MyExtensions = { logger: { log: (message: string) => void } }
23
- *
24
- * const command = defineWithTypes<{ extensions: MyExtensions }>()({
25
- * name: 'greet',
26
- * args: {
27
- * name: { type: 'string' }
28
- * },
29
- * run: ctx => {
30
- * // ctx.values is inferred as { name?: string }
31
- * // ctx.extensions is MyExtensions
32
- * }
33
- * })
34
- * ```
35
- *
36
- * @typeParam G - A {@link GunshiParams} type
37
- *
38
- * @returns A function that takes a command definition via {@link define}
39
- *
40
- * @since v0.27.0
41
- */
42
- function defineWithTypes() {
43
- return (definition) => {
44
- return define(definition);
45
- };
46
- }
47
- /**
48
- * Define a {@link LazyCommand | lazy command} with or without definition.
49
- *
50
- * @param loader - A {@link CommandLoader | command loader} function that returns a command definition
51
- * @param definition - An optional {@link Command | command} definition
52
- * @returns A {@link LazyCommand | lazy command} that can be executed later
53
- */
54
- function lazy(loader, definition) {
55
- const lazyCommand = loader;
56
- if (definition != null) {
57
- lazyCommand.commandName = definition.name;
58
- lazyCommand.description = definition.description;
59
- lazyCommand.args = definition.args;
60
- lazyCommand.examples = definition.examples;
61
- lazyCommand.internal = definition.internal;
62
- lazyCommand.entry = definition.entry;
63
- lazyCommand.toKebab = definition.toKebab;
64
- if ("resource" in definition) lazyCommand.resource = definition.resource;
65
- }
66
- return lazyCommand;
67
- }
68
- /**
69
- * Define a {@link LazyCommand | lazy command} with specific type parameters.
70
- *
71
- * This helper function allows specifying the type parameter of {@link GunshiParams}
72
- * while inferring the {@link Args} type, {@link ExtendContext} type from the definition.
73
- *
74
- * @example
75
- * ```ts
76
- * type MyExtensions = { logger: { log: (message: string) => void } }
77
- *
78
- * const command = lazyWithTypes<{ extensions: MyExtensions }>()(
79
- * () => {
80
- * return ctx => {
81
- * // Command runner implementation
82
- * ctx.extensions.logger?.log('Command executed')
83
- * },
84
- * {
85
- * name: 'lazy-command',
86
- * args: {
87
- * opt: {
88
- * type: 'string',
89
- * description: 'An optional string argument',
90
- * required: false,
91
- * },
92
- * },
93
- * )
94
- * ```
95
- *
96
- * @typeParam G - A {@link GunshiParams} type
97
- *
98
- * @returns A function that takes a lazy command definition via {@link lazy}
99
- *
100
- * @since v0.27.0
101
- */
102
- function lazyWithTypes() {
103
- return (loader, definition) => {
104
- return lazy(loader, definition);
105
- };
106
- }
107
-
108
- //#endregion
109
- export { lazyWithTypes as i, defineWithTypes as n, lazy as r, define as t };
File without changes