gunshi 0.27.0-beta.3 → 0.27.0-beta.4

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,6 +1,10 @@
1
- import { ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, Prettify, RendererDecorator, RenderingOptions, ValidationErrorsDecorator } from "./types-DpGOiC0p.js";
1
+ import { A as ValidationErrorsDecorator, 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, 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-DIfsK4mZ.js";
2
2
 
3
3
  //#region src/cli/bone.d.ts
4
+ /**
5
+ * @author kazuya kawaguchi (a.k.a. kazupon)
6
+ * @license MIT
7
+ */
4
8
 
5
9
  /**
6
10
  * Run the command.
package/lib/bone.js CHANGED
@@ -1,9 +1,13 @@
1
- import "./context-CaqWZ3MF.js";
2
- import "./utils-Bh4TdPy8.js";
3
- import { cliCore } from "./core-clRbigv-.js";
1
+ import "./context-DRQZ3doU.js";
2
+ import "./utils-DA31tfdY.js";
3
+ import { t as cliCore } from "./core-D15eimMG.js";
4
4
 
5
5
  //#region src/cli/bone.ts
6
6
  /**
7
+ * @author kazuya kawaguchi (a.k.a. kazupon)
8
+ * @license MIT
9
+ */
10
+ /**
7
11
  * Run the command.
8
12
  *
9
13
  * @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command and cli options.
@@ -1,9 +1,13 @@
1
- import { cliCore } from "./core-clRbigv-.js";
2
- import { plugin } from "./plugin-BRVcC8lF.js";
3
- import { COMMON_ARGS, namespacedId, renderer } from "./src-hz2EqFqR.js";
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-DZnfAAwF.js";
4
4
 
5
5
  //#region ../plugin-global/src/types.ts
6
6
  /**
7
+ * @author kazuya kawaguchi (a.k.a. kazupon)
8
+ * @license MIT
9
+ */
10
+ /**
7
11
  * The unique identifier for the global options plugin.
8
12
  */
9
13
  const pluginId = namespacedId("global");
@@ -11,6 +15,10 @@ const pluginId = namespacedId("global");
11
15
  //#endregion
12
16
  //#region ../plugin-global/src/decorator.ts
13
17
  /**
18
+ * @author kazuya kawaguchi (a.k.a. kazupon)
19
+ * @license MIT
20
+ */
21
+ /**
14
22
  * Decorator function to extend the command with global options.
15
23
  *
16
24
  * @param baseRunner - The base command runner
@@ -84,6 +92,35 @@ function extension(ctx) {
84
92
  //#endregion
85
93
  //#region ../plugin-global/src/index.ts
86
94
  /**
95
+ * The entry point of global options plugin
96
+ *
97
+ * @example
98
+ * ```js
99
+ * import global from '@gunshi/plugin-global'
100
+ * import { cli } from 'gunshi'
101
+ *
102
+ * const entry = (ctx) => {
103
+ * // ...
104
+ * }
105
+ *
106
+ * await cli(process.argv.slice(2), entry, {
107
+ * // ...
108
+ *
109
+ * plugins: [
110
+ * global()
111
+ * ],
112
+ *
113
+ * // ...
114
+ * })
115
+ * ```
116
+ *
117
+ * @module
118
+ */
119
+ /**
120
+ * @author kazuya kawaguchi (a.k.a. kazupon)
121
+ * @license MIT
122
+ */
123
+ /**
87
124
  * global options plugin
88
125
  *
89
126
  * @returns A defined plugin as global options
@@ -103,6 +140,10 @@ function global() {
103
140
  //#endregion
104
141
  //#region src/cli/builtin.ts
105
142
  /**
143
+ * @author kazuya kawaguchi (a.k.a. kazupon)
144
+ * @license MIT
145
+ */
146
+ /**
106
147
  * Run the command.
107
148
  *
108
149
  * @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command and cli options.
@@ -117,4 +158,4 @@ async function cli(args, entry, options = {}) {
117
158
  }
118
159
 
119
160
  //#endregion
120
- export { cli };
161
+ export { cli as t };
@@ -1,4 +1,4 @@
1
- import { ArgToken, ArgValues, Args, CliOptions, Command, CommandCallMode, CommandContext, CommandContextExtension, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, GunshiParams, GunshiParamsConstraint, LazyCommand } from "./types-DpGOiC0p.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-DIfsK4mZ.js";
2
2
 
3
3
  //#region src/context.d.ts
4
4
 
@@ -94,4 +94,4 @@ declare function createCommandContext<G extends GunshiParamsConstraint = Default
94
94
  extensions: ExtractExtensions<E>;
95
95
  }>>>>;
96
96
  //#endregion
97
- export { CommandContextParams, ExtractExtensions, createCommandContext };
97
+ export { ExtractExtensions as n, createCommandContext as r, CommandContextParams as t };
@@ -1,4 +1,4 @@
1
- import { create, deepFreeze, isLazyCommand, log } from "./utils-Bh4TdPy8.js";
1
+ import { a as log, n as deepFreeze, r as isLazyCommand, t as create } from "./utils-DA31tfdY.js";
2
2
 
3
3
  //#region src/constants.ts
4
4
  const ANONYMOUS_COMMAND_NAME = "(anonymous)";
@@ -27,6 +27,21 @@ const CLI_OPTIONS_DEFAULT = {
27
27
  //#endregion
28
28
  //#region src/context.ts
29
29
  /**
30
+ * The entry for gunshi context.
31
+ * This module is exported for the purpose of testing the command.
32
+ *
33
+ * @example
34
+ * ```js
35
+ * import { createCommandContext } from 'gunshi/context'
36
+ * ```
37
+ *
38
+ * @module
39
+ */
40
+ /**
41
+ * @author kazuya kawaguchi (a.k.a. kazupon)
42
+ * @license MIT
43
+ */
44
+ /**
30
45
  * Create a command context.
31
46
  *
32
47
  * @param param - A {@link CommandContextParams | parameters} to create a command context.
@@ -98,4 +113,4 @@ function getCommandName(cmd) {
98
113
  }
99
114
 
100
115
  //#endregion
101
- export { ANONYMOUS_COMMAND_NAME, CLI_OPTIONS_DEFAULT, NOOP, createCommandContext };
116
+ export { NOOP as i, ANONYMOUS_COMMAND_NAME as n, CLI_OPTIONS_DEFAULT as r, createCommandContext as t };
package/lib/context.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import "./types-DpGOiC0p.js";
2
- import { CommandContextParams, ExtractExtensions, createCommandContext } from "./context-C7rkDQK3.js";
1
+ import "./types-DIfsK4mZ.js";
2
+ import { n as ExtractExtensions, r as createCommandContext, t as CommandContextParams } from "./context-CMrZI9J4.js";
3
3
  export { CommandContextParams, ExtractExtensions, createCommandContext };
package/lib/context.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createCommandContext } from "./context-CaqWZ3MF.js";
2
- import "./utils-Bh4TdPy8.js";
1
+ import { t as createCommandContext } from "./context-DRQZ3doU.js";
2
+ import "./utils-DA31tfdY.js";
3
3
 
4
4
  export { createCommandContext };
@@ -1,9 +1,9 @@
1
- import { ANONYMOUS_COMMAND_NAME, CLI_OPTIONS_DEFAULT, NOOP, createCommandContext } from "./context-CaqWZ3MF.js";
2
- import { create, isLazyCommand, resolveLazyCommand } from "./utils-Bh4TdPy8.js";
1
+ import { i as NOOP, n as ANONYMOUS_COMMAND_NAME, r as CLI_OPTIONS_DEFAULT, t as createCommandContext } from "./context-DRQZ3doU.js";
2
+ import { o as resolveLazyCommand, r as isLazyCommand, t as create } from "./utils-DA31tfdY.js";
3
3
  import { parseArgs, resolveArgs } from "args-tokens";
4
4
 
5
5
  //#region src/decorators.ts
6
- const EMPTY_RENDERER = async () => "";
6
+ const EMPTY_RENDERER = () => Promise.resolve("");
7
7
  /**
8
8
  * Factory function for creating a decorators manager.
9
9
  *
@@ -162,6 +162,10 @@ function resolveDependencies(plugins) {
162
162
  //#endregion
163
163
  //#region src/cli/core.ts
164
164
  /**
165
+ * @author kazuya kawaguchi (a.k.a. kazupon)
166
+ * @license MIT
167
+ */
168
+ /**
165
169
  * Run the command.
166
170
  *
167
171
  * @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command and cli options.
@@ -179,7 +183,7 @@ async function cliCore(argv, entry, options, plugins) {
179
183
  const cliOptions = normalizeCliOptions(options, decorators, pluginContext);
180
184
  const tokens = parseArgs(argv);
181
185
  const subCommand = getSubCommand(tokens);
182
- const { commandName: name, command, callMode } = await resolveCommand(subCommand, entry, cliOptions);
186
+ const { commandName: name, command, callMode } = resolveCommand(subCommand, entry, cliOptions);
183
187
  if (!command) throw new Error(`Command not found: ${name || ""}`);
184
188
  const args = resolveArguments(pluginContext, getCommandArgs(command));
185
189
  const { explicit, values, positionals, rest, error } = resolveArgs(args, tokens, {
@@ -262,9 +266,9 @@ function getSubCommand(tokens) {
262
266
  return firstToken && firstToken.kind === "positional" && firstToken.index === 0 && firstToken.value ? firstToken.value : "";
263
267
  }
264
268
  const CANNOT_RESOLVE_COMMAND = { callMode: "unexpected" };
265
- async function resolveCommand(sub, entry, options) {
269
+ function resolveCommand(sub, entry, options) {
266
270
  const omitted = !sub;
267
- async function doResolveCommand() {
271
+ function doResolveCommand() {
268
272
  if (typeof entry === "function") if ("commandName" in entry && entry.commandName) return {
269
273
  commandName: entry.commandName,
270
274
  command: entry,
@@ -332,4 +336,4 @@ async function executeCommand(cmd, ctx, decorators) {
332
336
  }
333
337
 
334
338
  //#endregion
335
- export { cliCore };
339
+ export { cliCore as t };
@@ -1,6 +1,10 @@
1
- import { Args, Command, CommandLoader, DefaultGunshiParams, ExtendContext, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, Prettify } from "./types-DpGOiC0p.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-DIfsK4mZ.js";
2
2
 
3
3
  //#region src/definition.d.ts
4
+ /**
5
+ * @author kazuya kawaguchi (a.k.a. kazupon)
6
+ * @license MIT
7
+ */
4
8
 
5
9
  /**
6
10
  * Infer command properties excluding for {@link define} function
@@ -44,8 +48,8 @@ type CommandDefinitionResult<G extends GunshiParamsConstraint = DefaultGunshiPar
44
48
  * @param definition - A {@link Command | command} definition
45
49
  * @returns A defined {@link Command | command}
46
50
  */
47
- declare function define<G extends GunshiParamsConstraint = DefaultGunshiParams, A extends Args = ExtractArgs<G>, C extends InferCommandProps<G> = InferCommandProps<G>>(definition: C & Command<{
48
- args: A;
51
+ declare function define<G extends GunshiParamsConstraint = DefaultGunshiParams, A$1 extends Args = ExtractArgs<G>, C extends InferCommandProps<G> = InferCommandProps<G>>(definition: C & Command<{
52
+ args: A$1;
49
53
  extensions: ExtractExtensions<G>;
50
54
  }>): CommandDefinitionResult<G, C>;
51
55
  /**
@@ -55,14 +59,14 @@ declare function define<G extends GunshiParamsConstraint = DefaultGunshiParams,
55
59
  *
56
60
  * @internal
57
61
  */
58
- type DefineWithTypesReturn<DefaultExtensions extends ExtendContext, DefaultArgs extends Args> = <A extends DefaultArgs = DefaultArgs, C extends Partial<Command<{
59
- args: A;
62
+ type DefineWithTypesReturn<DefaultExtensions extends ExtendContext, DefaultArgs extends Args> = <A$1 extends DefaultArgs = DefaultArgs, C extends Partial<Command<{
63
+ args: A$1;
60
64
  extensions: DefaultExtensions;
61
65
  }>> = {}>(definition: C & Command<{
62
- args: A;
66
+ args: A$1;
63
67
  extensions: DefaultExtensions;
64
68
  }>) => CommandDefinitionResult<{
65
- args: A;
69
+ args: A$1;
66
70
  extensions: DefaultExtensions;
67
71
  }, C>;
68
72
  /**
@@ -109,11 +113,11 @@ declare function defineWithTypes<G extends GunshiParamsConstraint>(): DefineWith
109
113
  * @param loader - A {@link CommandLoader | command loader}
110
114
  * @returns A {@link LazyCommand | lazy command} with loader
111
115
  */
112
- declare function lazy<A extends Args>(loader: CommandLoader<{
113
- args: A;
116
+ declare function lazy<A$1 extends Args>(loader: CommandLoader<{
117
+ args: A$1;
114
118
  extensions: {};
115
119
  }>): LazyCommand<{
116
- args: A;
120
+ args: A$1;
117
121
  extensions: {};
118
122
  }, {}>;
119
123
  /**
@@ -151,17 +155,17 @@ declare function lazy<A extends Args>(loader: CommandLoader<{
151
155
  * @param definition - An optional {@link Command | command} definition
152
156
  * @returns A {@link LazyCommand | lazy command} that can be executed later
153
157
  */
154
- declare function lazy<G extends GunshiParamsConstraint = DefaultGunshiParams, A extends ExtractArgs<G> = ExtractArgs<G>, D extends Partial<Command<{
155
- args: A;
158
+ declare function lazy<G extends GunshiParamsConstraint = DefaultGunshiParams, A$1 extends ExtractArgs<G> = ExtractArgs<G>, D extends Partial<Command<{
159
+ args: A$1;
156
160
  extensions: {};
157
161
  }>> = Partial<Command<{
158
- args: A;
162
+ args: A$1;
159
163
  extensions: {};
160
164
  }>>>(loader: CommandLoader<{
161
- args: A;
165
+ args: A$1;
162
166
  extensions: {};
163
167
  }>, definition: D): LazyCommand<{
164
- args: A;
168
+ args: A$1;
165
169
  extensions: {};
166
170
  }, D>;
167
171
  /**
@@ -232,4 +236,4 @@ type LazyWithTypesReturn<FullG extends GunshiParamsConstraint> = <D extends Part
232
236
  */
233
237
  declare function lazyWithTypes<G extends GunshiParamsConstraint>(): LazyWithTypesReturn<NormalizeGunshiParams<G>>;
234
238
  //#endregion
235
- export { define, defineWithTypes, lazy, lazyWithTypes };
239
+ export { lazyWithTypes as i, defineWithTypes as n, lazy as r, define as t };
@@ -106,4 +106,4 @@ function lazyWithTypes() {
106
106
  }
107
107
 
108
108
  //#endregion
109
- export { define, defineWithTypes, lazy, lazyWithTypes };
109
+ export { lazyWithTypes as i, defineWithTypes as n, lazy as r, define as t };
@@ -1,4 +1,4 @@
1
- import { ArgSchema, ArgValues, Args, Command, CommandLoader, CommandRunner, DefaultGunshiParams, ExtendContext, GunshiParams, LazyCommand } from "./types-DpGOiC0p.js";
2
- import { CommandContextParams, createCommandContext } from "./context-C7rkDQK3.js";
3
- import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition-BPAFRYmH.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-DIfsK4mZ.js";
2
+ import { r as createCommandContext, t as CommandContextParams } from "./context-CMrZI9J4.js";
3
+ import { i as lazyWithTypes, n as defineWithTypes, r as lazy, t as define } from "./definition-BWGhvqMF.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,5 @@
1
- import { createCommandContext } from "./context-CaqWZ3MF.js";
2
- import "./utils-Bh4TdPy8.js";
3
- import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition-qbPc8FcH.js";
1
+ import { t as createCommandContext } from "./context-DRQZ3doU.js";
2
+ import "./utils-DA31tfdY.js";
3
+ import { i as lazyWithTypes, n as defineWithTypes, r as lazy, t as define } from "./definition-D5821Sur.js";
4
4
 
5
5
  export { createCommandContext, define, defineWithTypes, lazy, lazyWithTypes };
@@ -1,4 +1,4 @@
1
- import { CliOptions, Command, DefaultGunshiParams, GunshiParamsConstraint, LazyCommand } from "./types-DpGOiC0p.js";
1
+ import { T as LazyCommand, o as CliOptions, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint } from "./types-DIfsK4mZ.js";
2
2
 
3
3
  //#region src/generator.d.ts
4
4
 
package/lib/generator.js CHANGED
@@ -1,12 +1,26 @@
1
- import "./context-CaqWZ3MF.js";
2
- import { create } from "./utils-Bh4TdPy8.js";
3
- import "./core-clRbigv-.js";
4
- import "./plugin-BRVcC8lF.js";
5
- import "./src-hz2EqFqR.js";
6
- import { cli } from "./cli-B121JwoR.js";
1
+ import "./context-DRQZ3doU.js";
2
+ import { t as create } from "./utils-DA31tfdY.js";
3
+ import "./core-D15eimMG.js";
4
+ import "./plugin-bQlPfOlH.js";
5
+ import "./src-DZnfAAwF.js";
6
+ import { t as cli } from "./cli-CTN-xtKX.js";
7
7
 
8
8
  //#region src/generator.ts
9
9
  /**
10
+ * The entry for usage generator.
11
+ *
12
+ * @example
13
+ * ```js
14
+ * import { generate } from 'gunshi/generator'
15
+ * ```
16
+ *
17
+ * @module
18
+ */
19
+ /**
20
+ * @author kazuya kawaguchi (a.k.a. kazupon)
21
+ * @license MIT
22
+ */
23
+ /**
10
24
  * Generate the command usage.
11
25
  *
12
26
  * @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command parameters.
@@ -0,0 +1,158 @@
1
+ import { 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-DIfsK4mZ.js";
2
+ import { parseArgs as parseArgs$1, resolveArgs as resolveArgs$1 } from "args-tokens";
3
+
4
+ //#region ../plugin-i18n/src/types.d.ts
5
+
6
+ /**
7
+ * Translation adapter factory options.
8
+ */
9
+ interface TranslationAdapterFactoryOptions {
10
+ /**
11
+ * A locale (BCP 47 language tag).
12
+ */
13
+ locale: string;
14
+ /**
15
+ * A fallback locale.
16
+ *
17
+ * @default DEFAULT_LOCALE ('en-US')
18
+ */
19
+ fallbackLocale: string;
20
+ }
21
+ /**
22
+ * Translation adapter.
23
+ *
24
+ * This adapter is used to custom message formatter like {@link https://github.com/intlify/vue-i18n/blob/master/spec/syntax.ebnf | Intlify message format}, {@link https://github.com/tc39/proposal-intl-messageformat | `Intl.MessageFormat` (MF2)}, and etc.
25
+ * This adapter will support localization with your preferred message format.
26
+ */
27
+ interface TranslationAdapter<MessageResource = string> {
28
+ /**
29
+ * Get a resource of locale.
30
+ *
31
+ * @param locale - A Locale at the time of command execution. That is Unicord locale ID (BCP 47)
32
+ * @returns A resource of locale. if resource not found, return `undefined`.
33
+ */
34
+ getResource(locale: string): Record<string, string> | undefined;
35
+ /**
36
+ * Set a resource of locale.
37
+ *
38
+ * @param locale - A Locale at the time of command execution. That is Unicord locale ID (BCP 47)
39
+ * @param resource - A resource of locale
40
+ */
41
+ setResource(locale: string, resource: Record<string, string>): void;
42
+ /**
43
+ * Get a message of locale.
44
+ *
45
+ * @param locale - A Locale at the time of command execution. That is Unicord locale ID (BCP 47)
46
+ * @param key - A key of message resource
47
+ * @returns A message of locale. if message not found, return `undefined`.
48
+ */
49
+ getMessage(locale: string, key: string): MessageResource | undefined;
50
+ /**
51
+ * Translate a message.
52
+ *
53
+ * @param locale - A Locale at the time of command execution. That is Unicord locale ID (BCP 47)
54
+ * @param key - A key of message resource
55
+ * @param values - A values to be resolved in the message
56
+ * @returns A translated message, if message is not translated, return `undefined`.
57
+ */
58
+ translate(locale: string, key: string, values?: Record<string, unknown>): string | undefined;
59
+ }
60
+ //#endregion
61
+ //#region ../plugin-i18n/src/translation.d.ts
62
+ /**
63
+ * Default implementation of {@linkcode TranslationAdapter}.
64
+ */
65
+ declare class DefaultTranslation implements TranslationAdapter {
66
+ #private;
67
+ /**
68
+ * Creates a new instance of DefaultTranslation.
69
+ *
70
+ * @param options - Options for the translation adapter, see {@linkcode TranslationAdapterFactoryOptions}
71
+ */
72
+ constructor(options: TranslationAdapterFactoryOptions);
73
+ /**
74
+ * Get a resource of locale.
75
+ *
76
+ * @param locale - A locale of resource (BCP 47 language tag)
77
+ * @returns A resource of locale. If resource not found, return `undefined`.
78
+ */
79
+ getResource(locale: string): Record<string, string> | undefined;
80
+ /**
81
+ * Set a resource of locale.
82
+ *
83
+ * @param locale - A locale of resource (BCP 47 language tag)
84
+ * @param resource - A resource of locale
85
+ */
86
+ setResource(locale: string, resource: Record<string, string>): void;
87
+ /**
88
+ * Get a message of locale.
89
+ *
90
+ * @param locale - A locale of message (BCP 47 language tag)
91
+ * @param key - A key of message resource
92
+ * @returns A message of locale. If message not found, return `undefined`.
93
+ */
94
+ getMessage(locale: string, key: string): string | undefined;
95
+ /**
96
+ * Translate a message.
97
+ *
98
+ * @param locale - A locale of message (BCP 47 language tag)
99
+ * @param key - A key of message resource
100
+ * @param values - A values to interpolate in the message
101
+ * @returns A translated message, if message is not translated, return `undefined`.
102
+ */
103
+ translate(locale: string, key: string, values?: Record<string, unknown>): string | undefined;
104
+ }
105
+ //#endregion
106
+ //#region src/cli/builtin.d.ts
107
+ /**
108
+ * Run the command.
109
+ *
110
+ * @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command and cli options.
111
+ *
112
+ * @param args - Command line arguments
113
+ * @param entry - A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
114
+ * @param options - A {@link CliOptions | CLI options}
115
+ * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
116
+ */
117
+ declare function cli<G extends GunshiParamsConstraint>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
118
+ /**
119
+ * Run the command.
120
+ *
121
+ * @typeParam A - The type of {@linkcode Args | arguments} defined in the command and cli options.
122
+ *
123
+ * @param args - Command line arguments
124
+ * @param entry - A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
125
+ * @param options - A {@link CliOptions | CLI options}
126
+ * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
127
+ */
128
+ declare function cli<A extends Args$1 = Args$1, G extends GunshiParams = {
129
+ args: A;
130
+ extensions: {};
131
+ }>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
132
+ /**
133
+ * Run the command.
134
+ *
135
+ * @typeParam E - An {@linkcode ExtendContext} type to specify the shape of command and cli options.
136
+ *
137
+ * @param args - Command line arguments
138
+ * @param entry - A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
139
+ * @param options - A {@link CliOptions | CLI options}
140
+ * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
141
+ */
142
+ declare function cli<E extends ExtendContext = ExtendContext, G extends GunshiParams = {
143
+ args: Args$1;
144
+ extensions: E;
145
+ }>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
146
+ /**
147
+ * Run the command.
148
+ *
149
+ * @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command and cli options.
150
+ *
151
+ * @param args - Command line arguments
152
+ * @param entry - A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
153
+ * @param options - A {@link CliOptions | CLI options}
154
+ * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
155
+ */
156
+ declare function cli<G extends GunshiParams = DefaultGunshiParams>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
157
+ //#endregion
158
+ export { DefaultTranslation as i, resolveArgs$1 as n, cli as r, parseArgs$1 as t };
package/lib/index.d.ts CHANGED
@@ -1,161 +1,7 @@
1
- import { ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, OnPluginExtension, Plugin, PluginContext, PluginDependency, PluginExtension, PluginFunction, PluginOptions, PluginWithExtension, PluginWithoutExtension, Prettify, RendererDecorator, RenderingOptions, ValidationErrorsDecorator, plugin } from "./types-DpGOiC0p.js";
2
- import { CommandContextParams, createCommandContext } from "./context-C7rkDQK3.js";
3
- import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition-BPAFRYmH.js";
4
- import { ANONYMOUS_COMMAND_NAME } from "./constants-BX52JB9x.js";
5
- import { parseArgs, resolveArgs } from "args-tokens";
6
-
7
- //#region ../plugin-i18n/src/types.d.ts
8
-
9
- /**
10
- * Translation adapter factory options.
11
- */
12
- interface TranslationAdapterFactoryOptions {
13
- /**
14
- * A locale (BCP 47 language tag).
15
- */
16
- locale: string;
17
- /**
18
- * A fallback locale.
19
- *
20
- * @default DEFAULT_LOCALE ('en-US')
21
- */
22
- fallbackLocale: string;
23
- }
24
- /**
25
- * Translation adapter.
26
- *
27
- * This adapter is used to custom message formatter like {@link https://github.com/intlify/vue-i18n/blob/master/spec/syntax.ebnf | Intlify message format}, {@link https://github.com/tc39/proposal-intl-messageformat | `Intl.MessageFormat` (MF2)}, and etc.
28
- * This adapter will support localization with your preferred message format.
29
- */
30
- interface TranslationAdapter<MessageResource = string> {
31
- /**
32
- * Get a resource of locale.
33
- *
34
- * @param locale - A Locale at the time of command execution. That is Unicord locale ID (BCP 47)
35
- * @returns A resource of locale. if resource not found, return `undefined`.
36
- */
37
- getResource(locale: string): Record<string, string> | undefined;
38
- /**
39
- * Set a resource of locale.
40
- *
41
- * @param locale - A Locale at the time of command execution. That is Unicord locale ID (BCP 47)
42
- * @param resource - A resource of locale
43
- */
44
- setResource(locale: string, resource: Record<string, string>): void;
45
- /**
46
- * Get a message of locale.
47
- *
48
- * @param locale - A Locale at the time of command execution. That is Unicord locale ID (BCP 47)
49
- * @param key - A key of message resource
50
- * @returns A message of locale. if message not found, return `undefined`.
51
- */
52
- getMessage(locale: string, key: string): MessageResource | undefined;
53
- /**
54
- * Translate a message.
55
- *
56
- * @param locale - A Locale at the time of command execution. That is Unicord locale ID (BCP 47)
57
- * @param key - A key of message resource
58
- * @param values - A values to be resolved in the message
59
- * @returns A translated message, if message is not translated, return `undefined`.
60
- */
61
- translate(locale: string, key: string, values?: Record<string, unknown>): string | undefined;
62
- }
63
- //#endregion
64
- //#region ../plugin-i18n/src/translation.d.ts
65
- /**
66
- * Default implementation of {@linkcode TranslationAdapter}.
67
- */
68
- declare class DefaultTranslation implements TranslationAdapter {
69
- #private;
70
- /**
71
- * Creates a new instance of DefaultTranslation.
72
- *
73
- * @param options - Options for the translation adapter, see {@linkcode TranslationAdapterFactoryOptions}
74
- */
75
- constructor(options: TranslationAdapterFactoryOptions);
76
- /**
77
- * Get a resource of locale.
78
- *
79
- * @param locale - A locale of resource (BCP 47 language tag)
80
- * @returns A resource of locale. If resource not found, return `undefined`.
81
- */
82
- getResource(locale: string): Record<string, string> | undefined;
83
- /**
84
- * Set a resource of locale.
85
- *
86
- * @param locale - A locale of resource (BCP 47 language tag)
87
- * @param resource - A resource of locale
88
- */
89
- setResource(locale: string, resource: Record<string, string>): void;
90
- /**
91
- * Get a message of locale.
92
- *
93
- * @param locale - A locale of message (BCP 47 language tag)
94
- * @param key - A key of message resource
95
- * @returns A message of locale. If message not found, return `undefined`.
96
- */
97
- getMessage(locale: string, key: string): string | undefined;
98
- /**
99
- * Translate a message.
100
- *
101
- * @param locale - A locale of message (BCP 47 language tag)
102
- * @param key - A key of message resource
103
- * @param values - A values to interpolate in the message
104
- * @returns A translated message, if message is not translated, return `undefined`.
105
- */
106
- translate(locale: string, key: string, values?: Record<string, unknown>): string | undefined;
107
- }
108
- //#endregion
109
- //#region src/cli/builtin.d.ts
110
- /**
111
- * Run the command.
112
- *
113
- * @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command and cli options.
114
- *
115
- * @param args - Command line arguments
116
- * @param entry - A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
117
- * @param options - A {@link CliOptions | CLI options}
118
- * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
119
- */
120
- declare function cli<G extends GunshiParamsConstraint>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
121
- /**
122
- * Run the command.
123
- *
124
- * @typeParam A - The type of {@linkcode Args | arguments} defined in the command and cli options.
125
- *
126
- * @param args - Command line arguments
127
- * @param entry - A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
128
- * @param options - A {@link CliOptions | CLI options}
129
- * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
130
- */
131
- declare function cli<A extends Args = Args, G extends GunshiParams = {
132
- args: A;
133
- extensions: {};
134
- }>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
135
- /**
136
- * Run the command.
137
- *
138
- * @typeParam E - An {@linkcode ExtendContext} type to specify the shape of command and cli options.
139
- *
140
- * @param args - Command line arguments
141
- * @param entry - A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
142
- * @param options - A {@link CliOptions | CLI options}
143
- * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
144
- */
145
- declare function cli<E extends ExtendContext = ExtendContext, G extends GunshiParams = {
146
- args: Args;
147
- extensions: E;
148
- }>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
149
- /**
150
- * Run the command.
151
- *
152
- * @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command and cli options.
153
- *
154
- * @param args - Command line arguments
155
- * @param entry - A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
156
- * @param options - A {@link CliOptions | CLI options}
157
- * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
158
- */
159
- declare function cli<G extends GunshiParams = DefaultGunshiParams>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
160
- //#endregion
161
- export { ANONYMOUS_COMMAND_NAME, ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, type CommandContextParams, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, DefaultTranslation, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, type OnPluginExtension, type Plugin, type PluginContext, type PluginDependency, type PluginExtension, type PluginFunction, type PluginOptions, type PluginWithExtension, type PluginWithoutExtension, Prettify, RendererDecorator, RenderingOptions, ValidationErrorsDecorator, cli, createCommandContext, define, defineWithTypes, lazy, lazyWithTypes, parseArgs, plugin, resolveArgs };
1
+ import { A as ValidationErrorsDecorator, B as PluginContext, C as GunshiParams, D as Prettify, E as NormalizeToGunshiParams, F as PluginFunction, I as PluginOptions, L as PluginWithExtension, M as Plugin, N as PluginDependency, O as RendererDecorator, P as PluginExtension, R as PluginWithoutExtension, 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 OnPluginExtension, 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 plugin } from "./types-DIfsK4mZ.js";
2
+ import { r as createCommandContext, t as CommandContextParams } from "./context-CMrZI9J4.js";
3
+ import { i as lazyWithTypes, n as defineWithTypes, r as lazy, t as define } from "./definition-BWGhvqMF.js";
4
+ import { t as ANONYMOUS_COMMAND_NAME } from "./plugin-gv9ogu9N.js";
5
+ import { i as DefaultTranslation, n as resolveArgs, r as cli, t as parseArgs } from "./index-BDRk6VtJ.js";
6
+ import "./utils-BVBpgaJv.js";
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, ValidationErrorsDecorator, cli, createCommandContext, define, defineWithTypes, lazy, lazyWithTypes, parseArgs, plugin, resolveArgs };
package/lib/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { ANONYMOUS_COMMAND_NAME, createCommandContext } from "./context-CaqWZ3MF.js";
2
- import "./utils-Bh4TdPy8.js";
3
- import "./core-clRbigv-.js";
4
- import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition-qbPc8FcH.js";
5
- import { plugin } from "./plugin-BRVcC8lF.js";
6
- import { BUILT_IN_PREFIX, namespacedId } from "./src-hz2EqFqR.js";
7
- import { cli } from "./cli-B121JwoR.js";
1
+ import { n as ANONYMOUS_COMMAND_NAME, t as createCommandContext } from "./context-DRQZ3doU.js";
2
+ import "./utils-DA31tfdY.js";
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-DZnfAAwF.js";
7
+ import { t as cli } from "./cli-CTN-xtKX.js";
8
8
  import { parseArgs, resolveArgs } from "args-tokens";
9
9
 
10
10
  //#region ../plugin-i18n/src/translation.ts
@@ -46,4 +46,4 @@ function plugin(options = {}) {
46
46
  }
47
47
 
48
48
  //#endregion
49
- export { plugin };
49
+ export { plugin as t };
@@ -0,0 +1,11 @@
1
+ import { o as CliOptions, v as DefaultGunshiParams } from "./types-DIfsK4mZ.js";
2
+
3
+ //#region src/constants.d.ts
4
+ /**
5
+ * @author kazuya kawaguchi (a.k.a. kazupon)
6
+ * @license MIT
7
+ */
8
+ declare const ANONYMOUS_COMMAND_NAME = "(anonymous)";
9
+ declare const CLI_OPTIONS_DEFAULT: CliOptions<DefaultGunshiParams>;
10
+ //#endregion
11
+ export { CLI_OPTIONS_DEFAULT as n, ANONYMOUS_COMMAND_NAME as t };
package/lib/plugin.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ArgSchema, ArgToken, ArgValues, Args, Awaitable, Command, CommandContext, CommandContextCore, CommandContextExtension, CommandDecorator, CommandExamplesFetcher, CommandRunner, DefaultGunshiParams, ExtendContext, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, OnPluginExtension, Plugin, PluginContext, PluginDependency, PluginExtension, PluginFunction, PluginOptions, PluginWithExtension, PluginWithoutExtension, Prettify, RendererDecorator, ValidationErrorsDecorator, plugin } from "./types-DpGOiC0p.js";
2
- import { CommandContextParams, createCommandContext } from "./context-C7rkDQK3.js";
3
- import { ANONYMOUS_COMMAND_NAME, CLI_OPTIONS_DEFAULT } from "./constants-BX52JB9x.js";
4
- export { ANONYMOUS_COMMAND_NAME, type ArgSchema, type ArgToken, type ArgValues, type Args, type Awaitable, CLI_OPTIONS_DEFAULT, type Command, type CommandContext, type CommandContextCore, type CommandContextExtension, type CommandContextParams, type CommandDecorator, type CommandExamplesFetcher, type CommandRunner, type DefaultGunshiParams, type ExtendContext, type ExtractArgs, type ExtractExtensions, type GunshiParams, type GunshiParamsConstraint, type LazyCommand, type NormalizeToGunshiParams, type OnPluginExtension, type Plugin, type PluginContext, type PluginDependency, type PluginExtension, type PluginFunction, type PluginOptions, type PluginWithExtension, type PluginWithoutExtension, type Prettify, type RendererDecorator, type ValidationErrorsDecorator, createCommandContext, plugin };
1
+ import { A as ValidationErrorsDecorator, B as PluginContext, C as GunshiParams, D as Prettify, E as NormalizeToGunshiParams, F as PluginFunction, I as PluginOptions, L as PluginWithExtension, M as Plugin, N as PluginDependency, O as RendererDecorator, P as PluginExtension, R as PluginWithoutExtension, S as ExtractExtensions, T as LazyCommand, a as Awaitable, d as CommandContextExtension, f as CommandDecorator, g as CommandRunner, i as Args, j as OnPluginExtension, 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 plugin } from "./types-DIfsK4mZ.js";
2
+ import { r as createCommandContext, t as CommandContextParams } from "./context-CMrZI9J4.js";
3
+ import { n as CLI_OPTIONS_DEFAULT, t as ANONYMOUS_COMMAND_NAME } from "./plugin-gv9ogu9N.js";
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
- import { ANONYMOUS_COMMAND_NAME, CLI_OPTIONS_DEFAULT, createCommandContext } from "./context-CaqWZ3MF.js";
2
- import "./utils-Bh4TdPy8.js";
3
- import { plugin } from "./plugin-BRVcC8lF.js";
1
+ import { n as ANONYMOUS_COMMAND_NAME, r as CLI_OPTIONS_DEFAULT, t as createCommandContext } from "./context-DRQZ3doU.js";
2
+ import "./utils-DA31tfdY.js";
3
+ import { t as plugin } from "./plugin-bQlPfOlH.js";
4
4
 
5
5
  export { ANONYMOUS_COMMAND_NAME, CLI_OPTIONS_DEFAULT, createCommandContext, plugin };
package/lib/renderer.d.ts CHANGED
@@ -1,7 +1,15 @@
1
- import { CommandContext, DefaultGunshiParams, GunshiParams } from "./types-DpGOiC0p.js";
1
+ import { C as GunshiParams, l as CommandContext, v as DefaultGunshiParams } from "./types-DIfsK4mZ.js";
2
+ import "./context-CMrZI9J4.js";
3
+ import "./definition-BWGhvqMF.js";
4
+ import "./plugin-gv9ogu9N.js";
5
+ import "./index-BDRk6VtJ.js";
6
+ import "./utils-BVBpgaJv.js";
2
7
 
3
8
  //#region ../plugin-renderer/src/header.d.ts
4
-
9
+ /**
10
+ * @author kazuya kawaguchi (a.k.a. kazupon)
11
+ * @license MIT
12
+ */
5
13
  /**
6
14
  * Render the header.
7
15
  *
package/lib/renderer.js CHANGED
@@ -1,6 +1,6 @@
1
- import "./context-CaqWZ3MF.js";
2
- import "./utils-Bh4TdPy8.js";
3
- import "./plugin-BRVcC8lF.js";
4
- import { renderHeader, renderUsage, renderValidationErrors } from "./src-hz2EqFqR.js";
1
+ import "./context-DRQZ3doU.js";
2
+ import "./utils-DA31tfdY.js";
3
+ import "./plugin-bQlPfOlH.js";
4
+ import { i as renderHeader, n as renderValidationErrors, r as renderUsage } from "./src-DZnfAAwF.js";
5
5
 
6
6
  export { renderHeader, renderUsage, renderValidationErrors };
@@ -1,6 +1,6 @@
1
- import { ANONYMOUS_COMMAND_NAME } from "./context-CaqWZ3MF.js";
2
- import { kebabnize, resolveLazyCommand } from "./utils-Bh4TdPy8.js";
3
- import { plugin } from "./plugin-BRVcC8lF.js";
1
+ import { n as ANONYMOUS_COMMAND_NAME } from "./context-DRQZ3doU.js";
2
+ import { i as kebabnize, o as resolveLazyCommand } from "./utils-DA31tfdY.js";
3
+ import { t as plugin } from "./plugin-bQlPfOlH.js";
4
4
 
5
5
  //#region ../shared/src/constants.ts
6
6
  /**
@@ -29,38 +29,30 @@ const COMMON_ARGS = {
29
29
 
30
30
  //#endregion
31
31
  //#region ../resources/locales/en-US.json
32
- var COMMAND = "COMMAND";
33
- var COMMANDS = "COMMANDS";
34
- var SUBCOMMAND = "SUBCOMMAND";
35
- var USAGE = "USAGE";
36
- var ARGUMENTS = "ARGUMENTS";
37
- var OPTIONS = "OPTIONS";
38
- var EXAMPLES = "EXAMPLES";
39
- var FORMORE = "For more info, run any command with the `--help` flag";
40
32
  var NEGATABLE = "Negatable of";
41
- var DEFAULT = "default";
42
- var CHOICES = "choices";
43
- var help = "Display this help message";
44
- var version = "Display this version";
45
33
  var en_US_default = {
46
- COMMAND,
47
- COMMANDS,
48
- SUBCOMMAND,
49
- USAGE,
50
- ARGUMENTS,
51
- OPTIONS,
52
- EXAMPLES,
53
- FORMORE,
34
+ COMMAND: "COMMAND",
35
+ COMMANDS: "COMMANDS",
36
+ SUBCOMMAND: "SUBCOMMAND",
37
+ USAGE: "USAGE",
38
+ ARGUMENTS: "ARGUMENTS",
39
+ OPTIONS: "OPTIONS",
40
+ EXAMPLES: "EXAMPLES",
41
+ FORMORE: "For more info, run any command with the `--help` flag",
54
42
  NEGATABLE,
55
- DEFAULT,
56
- CHOICES,
57
- help,
58
- version
43
+ DEFAULT: "default",
44
+ CHOICES: "choices",
45
+ help: "Display this help message",
46
+ version: "Display this version"
59
47
  };
60
48
 
61
49
  //#endregion
62
50
  //#region ../shared/src/utils.ts
63
51
  /**
52
+ * @author kazuya kawaguchi (a.k.a. kazupon)
53
+ * @license MIT
54
+ */
55
+ /**
64
56
  * Resolve a namespaced key for built-in resources.
65
57
  *
66
58
  * Built-in keys are prefixed with "_:".
@@ -142,6 +134,10 @@ function makeShortLongOptionPair(schema, name, toKebab) {
142
134
  //#endregion
143
135
  //#region ../shared/src/localization.ts
144
136
  /**
137
+ * @author kazuya kawaguchi (a.k.a. kazupon)
138
+ * @license MIT
139
+ */
140
+ /**
145
141
  * Create a localizable function for a command.
146
142
  *
147
143
  * This function will resolve the translation key based on the command context and the provided translation function.
@@ -169,7 +165,7 @@ function localizable(ctx, cmd, translate) {
169
165
  }
170
166
  const schema = ctx.args[argKey];
171
167
  if (!schema) return argKey;
172
- return negatable && schema.type === "boolean" && schema.negatable ? `${en_US_default["NEGATABLE"]} ${makeShortLongOptionPair(schema, argKey, ctx.toKebab)}` : schema.description || "";
168
+ return negatable && schema.type === "boolean" && schema.negatable ? `${NEGATABLE} ${makeShortLongOptionPair(schema, argKey, ctx.toKebab)}` : schema.description || "";
173
169
  }
174
170
  if (key === resolveKey("description", ctx.name)) return "";
175
171
  else if (key === resolveKey("examples", ctx.name)) return await resolveExamples(ctx, cmd.examples);
@@ -194,12 +190,20 @@ function renderHeader(ctx) {
194
190
  //#endregion
195
191
  //#region ../plugin-renderer/src/types.ts
196
192
  /**
193
+ * @author kazuya kawaguchi (a.k.a. kazupon)
194
+ * @license MIT
195
+ */
196
+ /**
197
197
  * The unique identifier for usage renderer plugin.
198
198
  */
199
199
  const pluginId = namespacedId("renderer");
200
200
 
201
201
  //#endregion
202
202
  //#region ../plugin-renderer/src/usage.ts
203
+ /**
204
+ * @author kazuya kawaguchi (a.k.a. kazupon)
205
+ * @license MIT
206
+ */
203
207
  const COMMON_ARGS_KEYS = Object.keys(COMMON_ARGS);
204
208
  /**
205
209
  * Render the usage.
@@ -509,6 +513,35 @@ function renderValidationErrors(_ctx, error) {
509
513
 
510
514
  //#endregion
511
515
  //#region ../plugin-renderer/src/index.ts
516
+ /**
517
+ * The entry point of usage renderer plugin
518
+ *
519
+ * @example
520
+ * ```js
521
+ * import renderer from '@gunshi/plugin-renderer'
522
+ * import { cli } from 'gunshi'
523
+ *
524
+ * const entry = (ctx) => {
525
+ * // ...
526
+ * }
527
+ *
528
+ * await cli(process.argv.slice(2), entry, {
529
+ * // ...
530
+ *
531
+ * plugins: [
532
+ * renderer()
533
+ * ],
534
+ *
535
+ * // ...
536
+ * })
537
+ * ```
538
+ *
539
+ * @module
540
+ */
541
+ /**
542
+ * @author kazuya kawaguchi (a.k.a. kazupon)
543
+ * @license MIT
544
+ */
512
545
  const i18nPluginId = namespacedId("i18n");
513
546
  const dependencies = [{
514
547
  id: i18nPluginId,
@@ -524,7 +557,7 @@ function renderer() {
524
557
  id: pluginId,
525
558
  name: "usage renderer",
526
559
  dependencies,
527
- extension: async (ctx, cmd) => {
560
+ extension: (ctx, cmd) => {
528
561
  const i18n = ctx.extensions[i18nPluginId];
529
562
  let cachedCommands;
530
563
  async function loadCommands() {
@@ -555,4 +588,4 @@ function renderer() {
555
588
  }
556
589
 
557
590
  //#endregion
558
- export { BUILT_IN_PREFIX, COMMON_ARGS, namespacedId, renderHeader, renderUsage, renderValidationErrors, renderer };
591
+ export { namespacedId as a, renderHeader as i, renderValidationErrors as n, BUILT_IN_PREFIX as o, renderUsage as r, COMMON_ARGS as s, renderer as t };
@@ -1,6 +1,10 @@
1
1
  import { ArgExplicitlyProvided, ArgSchema, ArgSchema as ArgSchema$1, ArgToken, ArgToken as ArgToken$1, ArgValues, ArgValues as ArgValues$1, Args, Args as Args$1 } from "args-tokens";
2
2
 
3
3
  //#region src/plugin/context.d.ts
4
+ /**
5
+ * @author kazuya kawaguchi (a.k.a. kazupon)
6
+ * @license MIT
7
+ */
4
8
 
5
9
  /**
6
10
  * Type helper to create GunshiParams from extracted args and extensions
@@ -89,18 +93,18 @@ interface PluginContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
89
93
  }
90
94
  //#endregion
91
95
  //#region src/plugin/core.d.ts
92
- type ProcessDependency<D, A extends ExtendContext> = D extends string ? D extends keyof A ? { [K in D]: A[K] } : {} : D extends {
96
+ type ProcessDependency<D, A$1 extends ExtendContext> = D extends string ? D extends keyof A$1 ? { [K in D]: A$1[K] } : {} : D extends {
93
97
  id: infer ID;
94
98
  optional?: any;
95
- } ? ID extends string ? ID extends keyof A ? D extends {
99
+ } ? ID extends string ? ID extends keyof A$1 ? D extends {
96
100
  optional: true;
97
- } ? { [K in ID]: A[K] | undefined } : { [K in ID]: A[K] } : {} : never : never;
101
+ } ? { [K in ID]: A$1[K] | undefined } : { [K in ID]: A$1[K] } : {} : never : never;
98
102
  /**
99
103
  * Helper type to infer dependency extensions with optional support
100
104
  *
101
105
  * @internal
102
106
  */
103
- type InferDependencyExtensions<D extends ReadonlyArray<PluginDependency | string>, A extends ExtendContext> = D extends readonly [] ? {} : D extends readonly [infer First, ...infer Rest] ? ProcessDependency<First, A> & (Rest extends ReadonlyArray<PluginDependency | string> ? InferDependencyExtensions<Rest, A> : {}) : {};
107
+ type InferDependencyExtensions<D extends ReadonlyArray<PluginDependency | string>, A$1 extends ExtendContext> = D extends readonly [] ? {} : D extends readonly [infer First, ...infer Rest] ? ProcessDependency<First, A$1> & (Rest extends ReadonlyArray<PluginDependency | string> ? InferDependencyExtensions<Rest, A$1> : {}) : {};
104
108
  /**
105
109
  * Plugin dependency definition
106
110
  *
@@ -206,11 +210,11 @@ ResolvedDepExt extends GunshiParams = GunshiParams<{
206
210
  *
207
211
  * @since v0.27.0
208
212
  */
209
- type Plugin<E extends GunshiParams['extensions'] = DefaultGunshiParams['extensions']> = PluginFunction & {
213
+ type Plugin<E$1 extends GunshiParams['extensions'] = DefaultGunshiParams['extensions']> = PluginFunction & {
210
214
  id: string;
211
215
  name?: string;
212
216
  dependencies?: (PluginDependency | string)[];
213
- extension?: CommandContextExtension<E>;
217
+ extension?: CommandContextExtension<E$1>;
214
218
  };
215
219
  /**
216
220
  * Plugin return type with extension, which includes the plugin ID, name, dependencies, and extension.
@@ -219,7 +223,7 @@ type Plugin<E extends GunshiParams['extensions'] = DefaultGunshiParams['extensio
219
223
  *
220
224
  * @typeParam E - A type extending {@link GunshiParams} to specify the shape of {@linkcode CommandContext}'s extensions.
221
225
  */
222
- interface PluginWithExtension<E extends GunshiParams['extensions'] = DefaultGunshiParams['extensions']> extends Plugin<E> {
226
+ interface PluginWithExtension<E$1 extends GunshiParams['extensions'] = DefaultGunshiParams['extensions']> extends Plugin<E$1> {
223
227
  /**
224
228
  * Plugin identifier
225
229
  */
@@ -235,7 +239,7 @@ interface PluginWithExtension<E extends GunshiParams['extensions'] = DefaultGuns
235
239
  /**
236
240
  * Plugin extension
237
241
  */
238
- extension: CommandContextExtension<E>;
242
+ extension: CommandContextExtension<E$1>;
239
243
  }
240
244
  /**
241
245
  * Plugin return type without extension, which includes the plugin ID, name, and dependencies, but no extension.
@@ -244,7 +248,7 @@ interface PluginWithExtension<E extends GunshiParams['extensions'] = DefaultGuns
244
248
  *
245
249
  * @typeParam E - A type extending {@link GunshiParams} to specify the shape of {@linkcode CommandContext}'s extensions.
246
250
  */
247
- interface PluginWithoutExtension<E extends GunshiParams['extensions'] = DefaultGunshiParams['extensions']> extends Plugin<E> {
251
+ interface PluginWithoutExtension<E$1 extends GunshiParams['extensions'] = DefaultGunshiParams['extensions']> extends Plugin<E$1> {
248
252
  /**
249
253
  * Plugin identifier
250
254
  */
@@ -755,7 +759,7 @@ type CommandContextCore<G extends GunshiParamsConstraint = DefaultGunshiParams>
755
759
  *
756
760
  * @since v0.27.0
757
761
  */
758
- interface CommandContextExtension<E extends GunshiParams['extensions'] = DefaultGunshiParams['extensions']> {
762
+ interface CommandContextExtension<E$1 extends GunshiParams['extensions'] = DefaultGunshiParams['extensions']> {
759
763
  /**
760
764
  * Plugin identifier
761
765
  */
@@ -763,7 +767,7 @@ interface CommandContextExtension<E extends GunshiParams['extensions'] = Default
763
767
  /**
764
768
  * Plugin extension factory
765
769
  */
766
- readonly factory: (ctx: CommandContextCore, cmd: Command) => Awaitable<E>;
770
+ readonly factory: (ctx: CommandContextCore, cmd: Command) => Awaitable<E$1>;
767
771
  /**
768
772
  * Plugin extension factory after hook
769
773
  */
@@ -954,4 +958,4 @@ type RendererDecorator<T, G extends GunshiParamsConstraint = DefaultGunshiParams
954
958
  */
955
959
  type ValidationErrorsDecorator<G extends GunshiParamsConstraint = DefaultGunshiParams> = (baseRenderer: (ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>, ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>;
956
960
  //#endregion
957
- export { type ArgSchema$1 as ArgSchema, type ArgToken$1 as ArgToken, type ArgValues$1 as ArgValues, type Args$1 as Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, OnPluginExtension, Plugin, PluginContext, PluginDependency, PluginExtension, PluginFunction, PluginOptions, PluginWithExtension, PluginWithoutExtension, Prettify, RendererDecorator, RenderingOptions, ValidationErrorsDecorator, plugin };
961
+ export { ValidationErrorsDecorator as A, PluginContext as B, GunshiParams as C, Prettify as D, NormalizeToGunshiParams as E, PluginFunction as F, PluginOptions as I, PluginWithExtension as L, Plugin as M, PluginDependency as N, RendererDecorator as O, PluginExtension as P, PluginWithoutExtension as R, ExtractExtensions as S, LazyCommand as T, Commandable as _, Awaitable as a, ExtractArgExplicitlyProvided as b, CommandCallMode as c, CommandContextExtension as d, CommandDecorator as f, CommandRunner as g, CommandLoader as h, Args$1 as i, OnPluginExtension as j, RenderingOptions as k, CommandContext as l, CommandExamplesFetcher as m, ArgToken$1 as n, CliOptions as o, CommandEnvironment as p, ArgValues$1 as r, Command as s, ArgSchema$1 as t, CommandContextCore as u, DefaultGunshiParams as v, GunshiParamsConstraint as w, ExtractArgs as x, ExtendContext as y, plugin as z };
@@ -0,0 +1,50 @@
1
+ import { T as LazyCommand, _ as Commandable, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint } from "./types-DIfsK4mZ.js";
2
+ import { kebabnize } from "args-tokens/utils";
3
+
4
+ //#region src/utils.d.ts
5
+ /**
6
+ * @author kazuya kawaguchi (a.k.a. kazupon)
7
+ * @license MIT
8
+ */
9
+
10
+ /**
11
+ * Check if the given command is a {@link LazyCommand}.
12
+ *
13
+ * @param cmd - A command to check
14
+ * @returns `true` if the command is a {@link LazyCommand}, otherwise `false
15
+ */
16
+ declare function isLazyCommand<G extends GunshiParamsConstraint = DefaultGunshiParams>(cmd: unknown): cmd is LazyCommand<G>;
17
+ /**
18
+ * Resolve a lazy command to a {@link Command}.
19
+ *
20
+ * @param cmd - A {@link Commandable} or {@link LazyCommand} to resolve
21
+ * @param name - Optional name of the command, if not provided, it will use the name from the command itself.
22
+ * @param needRunResolving - Whether to run the resolving function of the lazy command.
23
+ * @returns A resolved {@link Command}
24
+ */
25
+ declare function resolveLazyCommand<G extends GunshiParamsConstraint = DefaultGunshiParams>(cmd: Commandable<G>, name?: string, needRunResolving?: boolean): Promise<Command<G>>;
26
+ /**
27
+ * Create an object with the specified prototype. A shorthand for `Object.create`.
28
+ *
29
+ * @param obj - An object to use as the prototype for the new object. If `null`, it will create an object with no prototype.
30
+ * @returns A new object with the specified prototype
31
+ */
32
+ declare function create<T>(obj?: object | null): T;
33
+ /**
34
+ * Log a message to the console.
35
+ *
36
+ * @param args - Arguments to log
37
+ */
38
+ declare function log(...args: unknown[]): void;
39
+ /**
40
+ * Deep freeze an object, making it immutable.
41
+ *
42
+ * @param obj - The object to freeze
43
+ * @param ignores - Properties to ignore during freezing
44
+ * @returns A frozen object
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>;
49
+ //#endregion
50
+ export { log as a, kebabnize as i, deepFreeze as n, resolveLazyCommand as o, isLazyCommand as r, create as t };
@@ -85,4 +85,4 @@ function deepFreeze(obj, ignores = []) {
85
85
  }
86
86
 
87
87
  //#endregion
88
- export { create, deepFreeze, isLazyCommand, kebabnize, log, resolveLazyCommand };
88
+ 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,46 +1,3 @@
1
- import { Command, Commandable, DefaultGunshiParams, GunshiParamsConstraint, LazyCommand } from "./types-DpGOiC0p.js";
2
- import { kebabnize } from "args-tokens/utils";
3
-
4
- //#region src/utils.d.ts
5
-
6
- /**
7
- * Check if the given command is a {@link LazyCommand}.
8
- *
9
- * @param cmd - A command to check
10
- * @returns `true` if the command is a {@link LazyCommand}, otherwise `false
11
- */
12
- declare function isLazyCommand<G extends GunshiParamsConstraint = DefaultGunshiParams>(cmd: unknown): cmd is LazyCommand<G>;
13
- /**
14
- * Resolve a lazy command to a {@link Command}.
15
- *
16
- * @param cmd - A {@link Commandable} or {@link LazyCommand} to resolve
17
- * @param name - Optional name of the command, if not provided, it will use the name from the command itself.
18
- * @param needRunResolving - Whether to run the resolving function of the lazy command.
19
- * @returns A resolved {@link Command}
20
- */
21
- declare function resolveLazyCommand<G extends GunshiParamsConstraint = DefaultGunshiParams>(cmd: Commandable<G>, name?: string | undefined, needRunResolving?: boolean): Promise<Command<G>>;
22
- /**
23
- * Create an object with the specified prototype. A shorthand for `Object.create`.
24
- *
25
- * @param obj - An object to use as the prototype for the new object. If `null`, it will create an object with no prototype.
26
- * @returns A new object with the specified prototype
27
- */
28
- declare function create<T>(obj?: object | null): T;
29
- /**
30
- * Log a message to the console.
31
- *
32
- * @param args - Arguments to log
33
- */
34
- declare function log(...args: unknown[]): void;
35
- /**
36
- * Deep freeze an object, making it immutable.
37
- *
38
- * @param obj - The object to freeze
39
- * @param ignores - Properties to ignore during freezing
40
- * @returns A frozen object
41
- */
42
- declare function deepFreeze<T extends Record<string, any>>(
43
- // eslint-disable-line @typescript-eslint/no-explicit-any -- NOTE(kazupon): generic type for deepFreeze
44
- obj: T, ignores?: string[]): Readonly<T>;
45
- //#endregion
1
+ import "./types-DIfsK4mZ.js";
2
+ import { a as log, i as kebabnize, n as deepFreeze, o as resolveLazyCommand, r as isLazyCommand, t as create } from "./utils-BVBpgaJv.js";
46
3
  export { create, deepFreeze, isLazyCommand, kebabnize, log, resolveLazyCommand };
package/lib/utils.js CHANGED
@@ -1,3 +1,3 @@
1
- import { create, deepFreeze, isLazyCommand, kebabnize, log, resolveLazyCommand } from "./utils-Bh4TdPy8.js";
1
+ import { a as log, i as kebabnize, n as deepFreeze, o as resolveLazyCommand, r as isLazyCommand, t as create } from "./utils-DA31tfdY.js";
2
2
 
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.0-beta.3",
4
+ "version": "0.27.0-beta.4",
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.4",
102
+ "deno": "^2.5.6",
103
103
  "jsr": "^0.13.5",
104
104
  "jsr-exports-lint": "^0.4.1",
105
- "publint": "^0.3.14",
106
- "tsdown": "0.15.9",
107
- "zod": "^4.1.12",
108
- "@gunshi/plugin-global": "0.27.0-beta.3",
109
- "@gunshi/plugin-i18n": "0.27.0-beta.3",
110
- "@gunshi/plugin-renderer": "0.27.0-beta.3",
111
- "@gunshi/resources": "0.27.0-beta.3",
112
- "@gunshi/shared": "0.27.0-beta.3"
105
+ "publint": "^0.3.15",
106
+ "tsdown": "0.15.12",
107
+ "zod": "^4.1.13",
108
+ "@gunshi/plugin-global": "0.27.0-beta.4",
109
+ "@gunshi/plugin-i18n": "0.27.0-beta.4",
110
+ "@gunshi/plugin-renderer": "0.27.0-beta.4",
111
+ "@gunshi/resources": "0.27.0-beta.4",
112
+ "@gunshi/shared": "0.27.0-beta.4"
113
113
  },
114
114
  "scripts": {
115
115
  "build": "tsdown",
@@ -1,8 +0,0 @@
1
- import { CliOptions, DefaultGunshiParams } from "./types-DpGOiC0p.js";
2
-
3
- //#region src/constants.d.ts
4
-
5
- declare const ANONYMOUS_COMMAND_NAME = "(anonymous)";
6
- declare const CLI_OPTIONS_DEFAULT: CliOptions<DefaultGunshiParams>;
7
- //#endregion
8
- export { ANONYMOUS_COMMAND_NAME, CLI_OPTIONS_DEFAULT };