gunshi 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  Gunshi is a modern javascript command-line library
12
12
 
13
- > [!TIP]
13
+ > [!TIP] <!-- eslint-disable-line markdown/no-missing-label-refs -->
14
14
  > gunshi (軍師) is a position in ancient Japanese samurai battle in which a samurai devised strategies and gave orders. That name is inspired by the word "command".
15
15
 
16
16
  ## ✨ Features
@@ -64,7 +64,7 @@ import { cli } from 'gunshi'
64
64
 
65
65
  const args = process.argv.slice(2)
66
66
  // run a simple command
67
- cli(args, () => {
67
+ await cli(args, () => {
68
68
  // something logic ...
69
69
  console.log('Hello from Gunshi!', args)
70
70
  })
@@ -103,7 +103,7 @@ const command = {
103
103
 
104
104
  // run a command that is defined above
105
105
  // (the 3rd argument of `cli` is the command option)
106
- cli(process.argv.slice(2), command, {
106
+ await cli(process.argv.slice(2), command, {
107
107
  name: 'my-app',
108
108
  version: '1.0.0',
109
109
  description: 'My CLI application'
@@ -201,7 +201,7 @@ const mainCommand = {
201
201
  }
202
202
 
203
203
  // run the CLI with composable sub-commands
204
- cli(process.argv.slice(2), mainCommand, {
204
+ await cli(process.argv.slice(2), mainCommand, {
205
205
  name: 'my-app',
206
206
  version: '1.0.0',
207
207
  subCommands
@@ -239,7 +239,7 @@ const subCommands = new Map()
239
239
  subCommands.set('lazy', lazyCommand)
240
240
 
241
241
  // run the CLI with lazy-loaded commands
242
- cli(
242
+ await cli(
243
243
  process.argv.slice(2),
244
244
  { name: 'main', run: () => {} },
245
245
  {
@@ -281,7 +281,7 @@ const command = {
281
281
  }
282
282
 
283
283
  // run with --help to see the automatically generated usage information
284
- cli(process.argv.slice(2), command, {
284
+ await cli(process.argv.slice(2), command, {
285
285
  name: 'my-app',
286
286
  version: '1.0.0'
287
287
  })
@@ -324,7 +324,7 @@ const customUsageRenderer = ctx => {
324
324
  }
325
325
 
326
326
  // run with custom renderers
327
- cli(
327
+ await cli(
328
328
  process.argv.slice(2),
329
329
  { name: 'app', run: () => {} },
330
330
  {
@@ -371,7 +371,7 @@ const command = {
371
371
  }
372
372
 
373
373
  // run with locale support
374
- cli(process.argv.slice(2), command, {
374
+ await cli(process.argv.slice(2), command, {
375
375
  name: 'my-app',
376
376
  version: '1.0.0',
377
377
  // set the locale via an environment variable
@@ -394,7 +394,8 @@ If you are interested in contributing to `gunshi`, I highly recommend checking o
394
394
 
395
395
  This project is inspired and powered by:
396
396
 
397
- - [`citty`](https://github.com/unjs/citty), created by UnJS team and contributors
397
+ - [`citty`](https://github.com/unjs/citty), created by [UnJS team](https://github.com/unjs) and contributors
398
+ - [`ordana`](https://github.com/sapphi-red/ordana), createdy by [sapphi-red](https://github.com/sapphi-red), inspired documentation generation
398
399
  - cline and claude 3.7 sonnet, examples and docs is generated
399
400
 
400
401
  Thank you!
@@ -1,4 +1,4 @@
1
- import { BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, DEFAULT_LOCALE, create, deepFreeze, mapResourceWithBuiltinKey, resolveLazyCommand } from "./utils-B39blQOf.js";
1
+ import { BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, DEFAULT_LOCALE, NOOP, create, deepFreeze, log, mapResourceWithBuiltinKey, resolveLazyCommand } from "./utils-jm146hfy.js";
2
2
 
3
3
  //#region locales/en-US.json
4
4
  var COMMAND = "COMMAND";
@@ -22,6 +22,40 @@ var en_US_default = {
22
22
  version
23
23
  };
24
24
 
25
+ //#endregion
26
+ //#region src/translation.ts
27
+ function createTranslationAdapter(options) {
28
+ return new DefaultTranslation(options);
29
+ }
30
+ var DefaultTranslation = class {
31
+ #resources = new Map();
32
+ options;
33
+ constructor(options) {
34
+ this.options = options;
35
+ this.#resources = new Map();
36
+ }
37
+ getResource(locale) {
38
+ return this.#resources.get(locale);
39
+ }
40
+ setResource(locale, resource) {
41
+ this.#resources.set(locale, resource);
42
+ }
43
+ getMessage(locale, key) {
44
+ const resource = this.getResource(locale);
45
+ if (resource) return resource[key];
46
+ return void 0;
47
+ }
48
+ translate(locale, key, _values = create()) {
49
+ /**
50
+ * NOTE:
51
+ * DefaultTranslation support static message only
52
+ * If you want to resolve message with values and use the complex message format,
53
+ * you should inherit this class or implement your own translation adapter.
54
+ */
55
+ return this.getMessage(locale, key) || this.getMessage(this.options.fallbackLocale, key);
56
+ }
57
+ };
58
+
25
59
  //#endregion
26
60
  //#region src/context.ts
27
61
  const BUILT_IN_PREFIX_CODE = BUILT_IN_PREFIX.codePointAt(0);
@@ -48,8 +82,12 @@ async function createCommandContext({ options, values, positionals, command, com
48
82
  */
49
83
  const env = Object.assign(create(), COMMAND_OPTIONS_DEFAULT, commandOptions);
50
84
  const locale = resolveLocale(commandOptions.locale);
85
+ const translationAdapterFactory = commandOptions.translationAdapterFactory || createTranslationAdapter;
86
+ const adapter = translationAdapterFactory({
87
+ locale: locale.toString(),
88
+ fallbackLocale: DEFAULT_LOCALE
89
+ });
51
90
  const localeResources = new Map();
52
- const commandResources = new Map();
53
91
  let builtInLoadedResources;
54
92
  /**
55
93
  * load the built-in locale resources
@@ -63,14 +101,12 @@ async function createCommandContext({ options, values, positionals, command, com
63
101
  * define the translation function, which is used to {@link CommandContext.translate}.
64
102
  *
65
103
  */
66
- function translate(key) {
67
- if (key.codePointAt(0) === BUILT_IN_PREFIX_CODE) {
104
+ function translate(key, values$1 = create()) {
105
+ const strKey = key;
106
+ if (strKey.codePointAt(0) === BUILT_IN_PREFIX_CODE) {
68
107
  const resource = localeResources.get(locale.toString()) || localeResources.get(DEFAULT_LOCALE);
69
- return resource[key] || key;
70
- } else {
71
- const resource = commandResources.get(locale.toString()) || commandResources.get(DEFAULT_LOCALE);
72
- return resource[key] || "";
73
- }
108
+ return resource[strKey] || strKey;
109
+ } else return adapter.translate(locale.toString(), strKey, values$1) || "";
74
110
  }
75
111
  /**
76
112
  * load the sub commands
@@ -94,6 +130,7 @@ async function createCommandContext({ options, values, positionals, command, com
94
130
  values: _values,
95
131
  positionals,
96
132
  usage,
133
+ log: commandOptions.usageSilent ? NOOP : log,
97
134
  loadCommands,
98
135
  translate
99
136
  }));
@@ -110,7 +147,7 @@ async function createCommandContext({ options, values, positionals, command, com
110
147
  }, create());
111
148
  defaultCommandResource.description = command.description || "";
112
149
  defaultCommandResource.examples = usage.examples || "";
113
- commandResources.set(DEFAULT_LOCALE, defaultCommandResource);
150
+ adapter.setResource(DEFAULT_LOCALE, defaultCommandResource);
114
151
  const originalResource = await loadCommandResource(ctx, command);
115
152
  if (originalResource) {
116
153
  const resource = Object.assign(create(), {
@@ -121,7 +158,7 @@ async function createCommandContext({ options, values, positionals, command, com
121
158
  resource.help = builtInLoadedResources.help;
122
159
  resource.version = builtInLoadedResources.version;
123
160
  }
124
- commandResources.set(locale.toString(), resource);
161
+ adapter.setResource(locale.toString(), resource);
125
162
  }
126
163
  return ctx;
127
164
  }
@@ -137,4 +174,4 @@ async function loadCommandResource(ctx, command) {
137
174
  }
138
175
 
139
176
  //#endregion
140
- export { createCommandContext };
177
+ export { DefaultTranslation, createCommandContext };
package/lib/context.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ArgOptions, ArgValues } from 'args-tokens';
2
- import { C as Command, a as CommandOptions, b as CommandContext } from './types.d-BvzTOO8I.js';
2
+ import { C as Command, a as CommandOptions, b as CommandContext } from './types.d-Dp0YJQNw.js';
3
3
 
4
4
  /**
5
5
  * Parameters of {@link createCommandContext}
package/lib/context.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createCommandContext } from "./context-CEZVz8Dg.js";
2
- import "./utils-B39blQOf.js";
1
+ import { createCommandContext } from "./context-DeTM_Qpg.js";
2
+ import "./utils-jm146hfy.js";
3
3
 
4
4
  export { createCommandContext };
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ArgOptions } from 'args-tokens';
2
2
  export { ArgOptionSchema, ArgOptions, ArgValues } from 'args-tokens';
3
- import { C as Command, c as CommandRunner, a as CommandOptions } from './types.d-BvzTOO8I.js';
4
- export { f as CommandBuiltinKeys, d as CommandBuiltinOptionsKeys, e as CommandBuiltinResourceKeys, b as CommandContext, g as CommandEnvironment, h as CommandResource, i as CommandResourceFetcher, j as Commandable, G as GenerateNamespacedKey, L as LazyCommand } from './types.d-BvzTOO8I.js';
3
+ import { C as Command, c as CommandRunner, a as CommandOptions, T as TranslationAdapter, d as TranslationAdapterFactoryOptions } from './types.d-Dp0YJQNw.js';
4
+ export { g as CommandBuiltinKeys, e as CommandBuiltinOptionsKeys, f as CommandBuiltinResourceKeys, b as CommandContext, h as CommandEnvironment, i as CommandResource, j as CommandResourceFetcher, l as Commandable, G as GenerateNamespacedKey, L as LazyCommand, k as TranslationAdapterFactory } from './types.d-Dp0YJQNw.js';
5
5
 
6
6
  /**
7
7
  * Run the command
@@ -11,4 +11,14 @@ export { f as CommandBuiltinKeys, d as CommandBuiltinOptionsKeys, e as CommandBu
11
11
  */
12
12
  declare function cli<Options extends ArgOptions = ArgOptions>(args: string[], entry: Command<Options> | CommandRunner<Options>, opts?: CommandOptions<Options>): Promise<string | undefined>;
13
13
 
14
- export { Command, CommandOptions, CommandRunner, cli };
14
+ declare class DefaultTranslation implements TranslationAdapter {
15
+ #private;
16
+ options: TranslationAdapterFactoryOptions;
17
+ constructor(options: TranslationAdapterFactoryOptions);
18
+ getResource(locale: string): Record<string, string> | undefined;
19
+ setResource(locale: string, resource: Record<string, string>): void;
20
+ getMessage(locale: string, key: string): string | undefined;
21
+ translate(locale: string, key: string, _values?: Record<string, unknown>): string | undefined;
22
+ }
23
+
24
+ export { Command, CommandOptions, CommandRunner, DefaultTranslation, TranslationAdapter, TranslationAdapterFactoryOptions, cli };
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { createCommandContext } from "./context-CEZVz8Dg.js";
2
- import { COMMAND_OPTIONS_DEFAULT, COMMON_OPTIONS, create, log, resolveLazyCommand } from "./utils-B39blQOf.js";
3
- import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-CD-yc-xk.js";
1
+ import { DefaultTranslation, createCommandContext } from "./context-DeTM_Qpg.js";
2
+ import { COMMAND_OPTIONS_DEFAULT, COMMON_OPTIONS, create, resolveLazyCommand } from "./utils-jm146hfy.js";
3
+ import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-DIRwkoRd.js";
4
4
  import { parseArgs, resolveArgs } from "args-tokens";
5
5
 
6
6
  //#region src/cli.ts
@@ -56,41 +56,41 @@ async function showUsage(ctx) {
56
56
  if (ctx.env.renderUsage === null) return;
57
57
  const usage = await (ctx.env.renderUsage || renderUsage)(ctx);
58
58
  if (usage) {
59
- log(usage);
59
+ ctx.log(usage);
60
60
  return usage;
61
61
  }
62
62
  }
63
63
  function showVersion(ctx) {
64
- log(ctx.env.version);
64
+ ctx.log(ctx.env.version);
65
65
  }
66
66
  async function showHeader(ctx) {
67
67
  if (ctx.env.renderHeader === null) return;
68
68
  const header = await (ctx.env.renderHeader || renderHeader)(ctx);
69
69
  if (header) {
70
- log(header);
71
- log();
70
+ ctx.log(header);
71
+ ctx.log();
72
72
  return header;
73
73
  }
74
74
  }
75
75
  async function showValidationErrors(ctx, error) {
76
76
  if (ctx.env.renderValidationErrors === null) return;
77
77
  const render = ctx.env.renderValidationErrors || renderValidationErrors;
78
- log(await render(ctx, error));
78
+ ctx.log(await render(ctx, error));
79
79
  }
80
80
  async function resolveCommand(sub, entry, options) {
81
81
  const omitted = !sub;
82
- if (typeof entry === "function") return [undefined, {
82
+ if (typeof entry === "function") return [void 0, {
83
83
  run: entry,
84
84
  default: true
85
85
  }];
86
- else if (omitted) return typeof entry === "object" ? [entry.name, await resolveLazyCommand(entry, undefined, true)] : [undefined, undefined];
86
+ else if (omitted) return typeof entry === "object" ? [entry.name, await resolveLazyCommand(entry, void 0, true)] : [void 0, void 0];
87
87
  else {
88
- if (options.subCommands == null) return [sub, undefined];
88
+ if (options.subCommands == null) return [sub, void 0];
89
89
  const cmd = options.subCommands?.get(sub);
90
- if (cmd == null) return [sub, undefined];
90
+ if (cmd == null) return [sub, void 0];
91
91
  return [sub, await resolveLazyCommand(cmd, sub)];
92
92
  }
93
93
  }
94
94
 
95
95
  //#endregion
96
- export { cli };
96
+ export { DefaultTranslation, cli };
@@ -1,5 +1,5 @@
1
1
  import { ArgOptions } from 'args-tokens';
2
- import { b as CommandContext } from '../types.d-BvzTOO8I.js';
2
+ import { b as CommandContext } from '../types.d-Dp0YJQNw.js';
3
3
 
4
4
  /**
5
5
  * Render the header
@@ -1,4 +1,4 @@
1
- import "../utils-B39blQOf.js";
2
- import { renderHeader, renderUsage, renderValidationErrors } from "../renderer-CD-yc-xk.js";
1
+ import "../utils-jm146hfy.js";
2
+ import { renderHeader, renderUsage, renderValidationErrors } from "../renderer-DIRwkoRd.js";
3
3
 
4
4
  export { renderHeader, renderUsage, renderValidationErrors };
@@ -1,4 +1,4 @@
1
- import { create, resolveBuiltInKey } from "./utils-B39blQOf.js";
1
+ import { create, resolveBuiltInKey } from "./utils-jm146hfy.js";
2
2
 
3
3
  //#region src/renderer/header.ts
4
4
  function renderHeader(ctx) {
@@ -6,6 +6,7 @@ import { ArgOptions, ArgValues } from 'args-tokens';
6
6
  declare const DEFAULT_LOCALE = "en-US";
7
7
  declare const BUILT_IN_PREFIX = "_";
8
8
  declare const BUILT_IN_KEY_SEPARATOR = ":";
9
+ declare const NOOP: () => void;
9
10
  type CommonOptionType = {
10
11
  readonly help: {
11
12
  readonly type: "boolean"
@@ -26,8 +27,9 @@ declare const __constants_COMMAND_BUILTIN_RESOURCE_KEYS: typeof COMMAND_BUILTIN_
26
27
  declare const __constants_COMMAND_OPTIONS_DEFAULT: typeof COMMAND_OPTIONS_DEFAULT;
27
28
  declare const __constants_COMMON_OPTIONS: typeof COMMON_OPTIONS;
28
29
  declare const __constants_DEFAULT_LOCALE: typeof DEFAULT_LOCALE;
30
+ declare const __constants_NOOP: typeof NOOP;
29
31
  declare namespace __constants {
30
- export { __constants_BUILT_IN_KEY_SEPARATOR as BUILT_IN_KEY_SEPARATOR, __constants_BUILT_IN_PREFIX as BUILT_IN_PREFIX, __constants_COMMAND_BUILTIN_RESOURCE_KEYS as COMMAND_BUILTIN_RESOURCE_KEYS, __constants_COMMAND_OPTIONS_DEFAULT as COMMAND_OPTIONS_DEFAULT, __constants_COMMON_OPTIONS as COMMON_OPTIONS, __constants_DEFAULT_LOCALE as DEFAULT_LOCALE };
32
+ export { __constants_BUILT_IN_KEY_SEPARATOR as BUILT_IN_KEY_SEPARATOR, __constants_BUILT_IN_PREFIX as BUILT_IN_PREFIX, __constants_COMMAND_BUILTIN_RESOURCE_KEYS as COMMAND_BUILTIN_RESOURCE_KEYS, __constants_COMMAND_OPTIONS_DEFAULT as COMMAND_OPTIONS_DEFAULT, __constants_COMMON_OPTIONS as COMMON_OPTIONS, __constants_DEFAULT_LOCALE as DEFAULT_LOCALE, __constants_NOOP as NOOP };
31
33
  }
32
34
 
33
35
  /**
@@ -98,6 +100,12 @@ interface CommandEnvironment<Options extends ArgOptions = ArgOptions> {
98
100
  */
99
101
  usageOptionType: boolean;
100
102
  /**
103
+ * Whether to display the command usage
104
+ * @default false
105
+ * @see {@link}
106
+ */
107
+ usageSilent: boolean;
108
+ /**
101
109
  * Sub commands
102
110
  * @see {@link CommandOptions.subCommands}
103
111
  */
@@ -157,6 +165,10 @@ interface CommandOptions<Options extends ArgOptions = ArgOptions> {
157
165
  */
158
166
  usageOptionType?: boolean;
159
167
  /**
168
+ * Whether to display the command usage
169
+ */
170
+ usageSilent?: boolean;
171
+ /**
160
172
  * Render function the command usage
161
173
  */
162
174
  renderUsage?: ((ctx: Readonly<CommandContext<Options>>) => Promise<string>) | null;
@@ -168,6 +180,11 @@ interface CommandOptions<Options extends ArgOptions = ArgOptions> {
168
180
  * Render function the validation errors
169
181
  */
170
182
  renderValidationErrors?: ((ctx: Readonly<CommandContext<Options>>, error: AggregateError) => Promise<string>) | null;
183
+ /**
184
+ * Translation adapter factory
185
+ * @experimental
186
+ */
187
+ translationAdapterFactory?: TranslationAdapterFactory;
171
188
  }
172
189
  /**
173
190
  * Command context
@@ -221,6 +238,13 @@ interface CommandContext<
221
238
  */
222
239
  usage: CommandUsage<Options>;
223
240
  /**
241
+ * Output a message
242
+ * @description if {@link CommandEnvironment.usageSilent} is true, the message is not output
243
+ * @param message an output message, @see {@link console.log}
244
+ * @param optionalParams an optional parameters, @see {@link console.log}
245
+ */
246
+ log: (message?: any, ...optionalParams: any[]) => void;
247
+ /**
224
248
  * Load sub-commands
225
249
  * @description The loaded commands are cached and returned when called again
226
250
  * @returns loaded commands
@@ -229,13 +253,14 @@ interface CommandContext<
229
253
  /**
230
254
  * Translate function
231
255
  * @param key the key to be translated
256
+ * @param values the values to be formatted
232
257
  * @returns A translated string
233
258
  * @experimental
234
259
  */
235
260
  translate: <
236
261
  T extends string = CommandBuiltinKeys,
237
262
  Key = CommandBuiltinKeys | keyof Options | T
238
- >(key: Key) => string;
263
+ >(key: Key, values?: Record<string, unknown>) => string;
239
264
  }
240
265
  /**
241
266
  * Command usage
@@ -315,6 +340,59 @@ type CommandResource<Options extends ArgOptions = ArgOptions> = {
315
340
  */
316
341
  type CommandResourceFetcher<Options extends ArgOptions = ArgOptions> = (ctx: Readonly<CommandContext<Options>>) => Promise<CommandResource<Options>>;
317
342
  /**
343
+ * Translation adapter factory
344
+ */
345
+ type TranslationAdapterFactory = (options: TranslationAdapterFactoryOptions) => TranslationAdapter;
346
+ /**
347
+ * Translation adapter factory options
348
+ */
349
+ interface TranslationAdapterFactoryOptions {
350
+ /**
351
+ * A locale
352
+ */
353
+ locale: string;
354
+ /**
355
+ * A fallback locale
356
+ */
357
+ fallbackLocale: string;
358
+ }
359
+ /**
360
+ * Translation adapter
361
+ *
362
+ * @description
363
+ * 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.
364
+ * This adapter will support localization with your preferred message format
365
+ */
366
+ interface TranslationAdapter<MessageResource = string> {
367
+ /**
368
+ * Get a resource of locale
369
+ * @param locale A Locale at the time of command execution. That is Unicord locale ID (BCP 47)
370
+ * @returns A resource of locale. if resource not found, return `undefined`
371
+ */
372
+ getResource(locale: string): Record<string, string> | undefined;
373
+ /**
374
+ * Set a resource of locale
375
+ * @param locale A Locale at the time of command execution. That is Unicord locale ID (BCP 47)
376
+ * @param resource A resource of locale
377
+ */
378
+ setResource(locale: string, resource: Record<string, string>): void;
379
+ /**
380
+ * Get a message of locale
381
+ * @param locale A Locale at the time of command execution. That is Unicord locale ID (BCP 47)
382
+ * @param key A key of message resource
383
+ * @returns A message of locale. if message not found, return `undefined`
384
+ */
385
+ getMessage(locale: string, key: string): MessageResource | undefined;
386
+ /**
387
+ * Translate a message
388
+ * @param locale A Locale at the time of command execution. That is Unicord locale ID (BCP 47)
389
+ * @param key A key of message resource
390
+ * @param values A values to be resolved in the message
391
+ * @returns A translated message, if message is not translated, return `undefined`
392
+ */
393
+ translate(locale: string, key: string, values?: Record<string, unknown>): string | undefined;
394
+ }
395
+ /**
318
396
  * Command runner
319
397
  * @param ctx A {@link CommandContext | command context}
320
398
  */
@@ -329,4 +407,4 @@ type LazyCommand<Options extends ArgOptions = ArgOptions> = () => Awaitable<Comm
329
407
  */
330
408
  type Commandable<Options extends ArgOptions> = Command<Options> | LazyCommand<Options>;
331
409
 
332
- export type { Command as C, GenerateNamespacedKey as G, LazyCommand as L, CommandOptions as a, CommandContext as b, CommandRunner as c, CommandBuiltinOptionsKeys as d, CommandBuiltinResourceKeys as e, CommandBuiltinKeys as f, CommandEnvironment as g, CommandResource as h, CommandResourceFetcher as i, Commandable as j };
410
+ export type { Command as C, GenerateNamespacedKey as G, LazyCommand as L, TranslationAdapter as T, CommandOptions as a, CommandContext as b, CommandRunner as c, TranslationAdapterFactoryOptions as d, CommandBuiltinOptionsKeys as e, CommandBuiltinResourceKeys as f, CommandBuiltinKeys as g, CommandEnvironment as h, CommandResource as i, CommandResourceFetcher as j, TranslationAdapterFactory as k, Commandable as l };
@@ -3,6 +3,7 @@
3
3
  const DEFAULT_LOCALE = "en-US";
4
4
  const BUILT_IN_PREFIX = "_";
5
5
  const BUILT_IN_KEY_SEPARATOR = ":";
6
+ const NOOP = () => {};
6
7
  const COMMON_OPTIONS = {
7
8
  help: {
8
9
  type: "boolean",
@@ -14,17 +15,19 @@ const COMMON_OPTIONS = {
14
15
  }
15
16
  };
16
17
  const COMMAND_OPTIONS_DEFAULT = {
17
- name: undefined,
18
- description: undefined,
19
- version: undefined,
20
- cwd: undefined,
21
- subCommands: undefined,
18
+ name: void 0,
19
+ description: void 0,
20
+ version: void 0,
21
+ cwd: void 0,
22
+ usageSilent: false,
23
+ subCommands: void 0,
22
24
  leftMargin: 2,
23
25
  middleMargin: 10,
24
26
  usageOptionType: false,
25
- renderHeader: undefined,
26
- renderUsage: undefined,
27
- renderValidationErrors: undefined
27
+ renderHeader: void 0,
28
+ renderUsage: void 0,
29
+ renderValidationErrors: void 0,
30
+ translationAdapterFactory: void 0
28
31
  };
29
32
 
30
33
  //#endregion
@@ -59,4 +62,4 @@ function deepFreeze(obj) {
59
62
  }
60
63
 
61
64
  //#endregion
62
- export { BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, COMMON_OPTIONS, DEFAULT_LOCALE, create, deepFreeze, log, mapResourceWithBuiltinKey, resolveBuiltInKey, resolveLazyCommand };
65
+ export { BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, COMMON_OPTIONS, DEFAULT_LOCALE, NOOP, create, deepFreeze, log, mapResourceWithBuiltinKey, resolveBuiltInKey, 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.7.0",
4
+ "version": "0.9.0",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -71,27 +71,34 @@
71
71
  },
72
72
  "devDependencies": {
73
73
  "@eslint/markdown": "^6.2.2",
74
- "@kazupon/eslint-config": "^0.22.0",
74
+ "@intlify/core": "next",
75
+ "@kazupon/eslint-config": "^0.26.1",
75
76
  "@kazupon/prettier-config": "^0.1.1",
76
77
  "@types/node": "^22.13.9",
77
78
  "@vitest/eslint-plugin": "^1.1.36",
78
79
  "bumpp": "^10.0.3",
79
- "eslint": "^9.21.0",
80
+ "eslint": "^9.22.0",
80
81
  "eslint-config-prettier": "^10.0.2",
82
+ "eslint-import-resolver-typescript": "^4.2.2",
83
+ "eslint-plugin-import": "^2.31.0",
81
84
  "eslint-plugin-jsonc": "^2.19.1",
85
+ "eslint-plugin-module-interop": "^0.3.0",
82
86
  "eslint-plugin-promise": "^7.2.1",
83
87
  "eslint-plugin-regexp": "^2.7.0",
84
88
  "eslint-plugin-unicorn": "^57.0.0",
89
+ "eslint-plugin-unused-imports": "^4.1.4",
85
90
  "eslint-plugin-yml": "^1.17.0",
86
91
  "gh-changelogen": "^0.2.8",
87
92
  "jsr": "^0.13.4",
88
93
  "knip": "^5.45.0",
89
94
  "lint-staged": "^15.4.3",
95
+ "messageformat": "4.0.0-10",
90
96
  "pkg-pr-new": "^0.0.41",
91
97
  "prettier": "^3.5.3",
92
98
  "tsdown": "^0.6.4",
93
99
  "typescript": "^5.4.2",
94
100
  "typescript-eslint": "^8.26.0",
101
+ "vitepress": "^1.6.3",
95
102
  "vitest": "^3.0.7"
96
103
  },
97
104
  "prettier": "@kazupon/prettier-config",
@@ -114,6 +121,9 @@
114
121
  "clean": "git clean -df",
115
122
  "dev": "pnpx @eslint/config-inspector --config eslint.config.ts",
116
123
  "dev:eslint": "pnpx @eslint/config-inspector --config eslint.config.ts",
124
+ "docs:build": "vitepress build docs",
125
+ "docs:dev": "vitepress dev docs",
126
+ "docs:preview": "vitepress preview docs",
117
127
  "fix": "pnpm run --stream --color \"/^fix:/\"",
118
128
  "fix:eslint": "eslint . --fix",
119
129
  "fix:knip": "knip --fix --no-exit-code",