gunshi 0.23.1 → 0.25.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
@@ -100,6 +100,7 @@ About more details and usage, see [documentations](https://gunshi.dev)
100
100
 
101
101
  - [pnpmc](https://github.com/kazupon/pnpmc): PNPM Catalogs Tooling
102
102
  - [sourcemap-publisher](https://github.com/es-tooling/sourcemap-publisher): A tool to publish sourcemaps externally and rewrite sourcemap URLs at pre-publish time
103
+ - [curxy](https://github.com/ryoppippi/curxy): An proxy worker for using ollama in cursor
103
104
 
104
105
  ## 🙌 Contributing guidelines
105
106
 
@@ -117,7 +118,7 @@ Thank you!
117
118
 
118
119
  ## 🤝 Sponsors
119
120
 
120
- The development of Gunish is supported by my OSS sponsors!
121
+ The development of Gunshi is supported by my OSS sponsors!
121
122
 
122
123
  <p align="center">
123
124
  <a href="https://cdn.jsdelivr.net/gh/kazupon/sponsors/sponsors.svg">
@@ -1,6 +1,6 @@
1
- import { ANONYMOUS_COMMAND_NAME, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, create, isLazyCommand, resolveLazyCommand } from "./utils-D41C8Abf.js";
2
- import { createCommandContext } from "./context-COFfMm-R.js";
3
- import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-kzo45gaB.js";
1
+ import { ANONYMOUS_COMMAND_NAME, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, create, isLazyCommand, resolveLazyCommand } from "./utils-B_QNzw5q.js";
2
+ import { createCommandContext } from "./context-DT5PgSdv.js";
3
+ import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-CTx2DsBI.js";
4
4
  import { parseArgs, resolveArgs } from "args-tokens";
5
5
 
6
6
  //#region src/cli.ts
@@ -19,7 +19,8 @@ async function cli(argv, entry, options = {}) {
19
19
  if (!command) throw new Error(`Command not found: ${name || ""}`);
20
20
  const args = resolveArguments(getCommandArgs(command));
21
21
  const { values, positionals, rest, error } = resolveArgs(args, tokens, {
22
- optionGrouping: true,
22
+ shortGrouping: true,
23
+ toKebab: command.toKebab,
23
24
  skipPositional: cliOptions.subCommands.size > 0 ? 0 : -1
24
25
  });
25
26
  const omitted = !subCommand;
@@ -1,4 +1,4 @@
1
- import { ANONYMOUS_COMMAND_NAME, BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, DEFAULT_LOCALE$1 as DEFAULT_LOCALE, NOOP, create, deepFreeze, isLazyCommand, log, mapResourceWithBuiltinKey, resolveArgKey, resolveExamples, resolveLazyCommand } from "./utils-D41C8Abf.js";
1
+ import { ANONYMOUS_COMMAND_NAME, BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, DEFAULT_LOCALE$1 as DEFAULT_LOCALE, NOOP, create, deepFreeze, isLazyCommand, log, mapResourceWithBuiltinKey, resolveArgKey, resolveExamples, resolveLazyCommand } from "./utils-B_QNzw5q.js";
2
2
 
3
3
  //#region src/locales/en-US.json
4
4
  var COMMAND = "COMMAND";
@@ -137,6 +137,7 @@ async function createCommandContext({ args, values, positionals, rest, argv, tok
137
137
  rest,
138
138
  _: argv,
139
139
  tokens,
140
+ toKebab: command.toKebab,
140
141
  log: cliOptions.usageSilent ? NOOP : log,
141
142
  loadCommands,
142
143
  translate
package/lib/context.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CliOptions, Command, CommandCallMode, CommandContext, LazyCommand } from "./types-BDWiiycu.js";
1
+ import { CliOptions, Command, CommandCallMode, CommandContext, LazyCommand } from "./types-B7j6WSjQ.js";
2
2
  import { ArgToken, ArgValues, Args } from "args-tokens";
3
3
 
4
4
  //#region src/context.d.ts
package/lib/context.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./utils-D41C8Abf.js";
2
- import { createCommandContext } from "./context-COFfMm-R.js";
1
+ import "./utils-B_QNzw5q.js";
2
+ import { createCommandContext } from "./context-DT5PgSdv.js";
3
3
 
4
4
  export { createCommandContext };
@@ -1,4 +1,4 @@
1
- import { Command, CommandLoader, LazyCommand } from "./types-BDWiiycu.js";
1
+ import { Command, CommandLoader, LazyCommand } from "./types-B7j6WSjQ.js";
2
2
  import { ArgSchema, ArgValues as ArgValues$1, Args, Args as Args$1 } from "args-tokens";
3
3
 
4
4
  //#region src/definition.d.ts
@@ -20,6 +20,7 @@ function lazy(loader, definition) {
20
20
  loader.args = definition.args;
21
21
  loader.examples = definition.examples;
22
22
  loader.resource = definition.resource;
23
+ loader.toKebab = definition.toKebab;
23
24
  }
24
25
  return loader;
25
26
  }
@@ -1,3 +1,3 @@
1
- import "./types-BDWiiycu.js";
2
- import { ArgSchema, ArgValues, Args, define$1 as define, lazy$1 as lazy } from "./definition-zTfMFgKw.js";
1
+ import "./types-B7j6WSjQ.js";
2
+ import { ArgSchema, ArgValues, Args, define$1 as define, lazy$1 as lazy } from "./definition-C3eTsvXE.js";
3
3
  export { ArgSchema, ArgValues, Args, define, lazy };
package/lib/definition.js CHANGED
@@ -1,3 +1,3 @@
1
- import { define, lazy } from "./definition-DyVBFqB7.js";
1
+ import { define, lazy } from "./definition-wq1Kmbvq.js";
2
2
 
3
3
  export { define, lazy };
@@ -1,4 +1,4 @@
1
- import { CliOptions, Command, LazyCommand } from "./types-BDWiiycu.js";
1
+ import { CliOptions, Command, LazyCommand } from "./types-B7j6WSjQ.js";
2
2
  import { Args } from "args-tokens";
3
3
 
4
4
  //#region src/generator.d.ts
package/lib/generator.js CHANGED
@@ -1,7 +1,7 @@
1
- import { create } from "./utils-D41C8Abf.js";
2
- import "./context-COFfMm-R.js";
3
- import "./renderer-kzo45gaB.js";
4
- import { cli } from "./cli-BVD3QITm.js";
1
+ import { create } from "./utils-B_QNzw5q.js";
2
+ import "./context-DT5PgSdv.js";
3
+ import "./renderer-CTx2DsBI.js";
4
+ import { cli } from "./cli-BtS9kKar.js";
5
5
 
6
6
  //#region src/generator.ts
7
7
  /**
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { CliOptions, Command, CommandArgKeys, CommandBuiltinArgsKeys, CommandBuiltinKeys, CommandBuiltinResourceKeys, CommandCallMode, CommandContext, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandResource, CommandResourceFetcher, CommandRunner, Commandable, DEFAULT_LOCALE, GenerateNamespacedKey, KeyOfArgs, LazyCommand, RemovedIndex, TranslationAdapter, TranslationAdapterFactory, TranslationAdapterFactoryOptions } from "./types-BDWiiycu.js";
2
- import { define$1 as define, lazy$1 as lazy } from "./definition-zTfMFgKw.js";
1
+ import { CliOptions, Command, CommandArgKeys, CommandBuiltinArgsKeys, CommandBuiltinKeys, CommandBuiltinResourceKeys, CommandCallMode, CommandContext, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandResource, CommandResourceFetcher, CommandRunner, Commandable, DEFAULT_LOCALE, GenerateNamespacedKey, KeyOfArgs, LazyCommand, RemovedIndex, TranslationAdapter, TranslationAdapterFactory, TranslationAdapterFactoryOptions } from "./types-B7j6WSjQ.js";
2
+ import { define$1 as define, lazy$1 as lazy } from "./definition-C3eTsvXE.js";
3
3
  import { ArgSchema, ArgValues, Args, Args as Args$1, parseArgs, resolveArgs } from "args-tokens";
4
4
 
5
5
  //#region src/cli.d.ts
package/lib/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { DEFAULT_LOCALE$1 as DEFAULT_LOCALE } from "./utils-D41C8Abf.js";
2
- import { DefaultTranslation } from "./context-COFfMm-R.js";
3
- import { define, lazy } from "./definition-DyVBFqB7.js";
4
- import "./renderer-kzo45gaB.js";
5
- import { cli } from "./cli-BVD3QITm.js";
1
+ import { DEFAULT_LOCALE$1 as DEFAULT_LOCALE } from "./utils-B_QNzw5q.js";
2
+ import { DefaultTranslation } from "./context-DT5PgSdv.js";
3
+ import { define, lazy } from "./definition-wq1Kmbvq.js";
4
+ import "./renderer-CTx2DsBI.js";
5
+ import { cli } from "./cli-BtS9kKar.js";
6
6
  import { parseArgs, resolveArgs } from "args-tokens";
7
7
 
8
8
  export { DEFAULT_LOCALE, DefaultTranslation, cli, define, lazy, parseArgs, resolveArgs };
@@ -1,4 +1,4 @@
1
- import { COMMON_ARGS, create, resolveArgKey, resolveBuiltInKey, resolveExamples } from "./utils-D41C8Abf.js";
1
+ import { COMMON_ARGS, create, kebabnize, resolveArgKey, resolveBuiltInKey, resolveExamples } from "./utils-B_QNzw5q.js";
2
2
 
3
3
  //#region src/renderer/header.ts
4
4
  /**
@@ -187,8 +187,9 @@ function hasAllDefaultOptions(ctx) {
187
187
  function generateOptionsSymbols(ctx) {
188
188
  return hasOptionalArgs(ctx) ? hasAllDefaultOptions(ctx) ? `[${ctx.translate(resolveBuiltInKey("OPTIONS"))}]` : `<${ctx.translate(resolveBuiltInKey("OPTIONS"))}>` : "";
189
189
  }
190
- function makeShortLongOptionPair(schema, name) {
191
- let key = `--${name}`;
190
+ function makeShortLongOptionPair(schema, name, toKebab) {
191
+ const displayName = toKebab || schema.toKebab ? kebabnize(name) : name;
192
+ let key = `--${displayName}`;
192
193
  if (schema.short) key = `-${schema.short}, ${key}`;
193
194
  return key;
194
195
  }
@@ -198,12 +199,18 @@ function makeShortLongOptionPair(schema, name) {
198
199
  * @returns Options pairs for usage
199
200
  */
200
201
  function getOptionalArgsPairs(ctx) {
201
- return Object.entries(ctx.args).reduce((acc, [name, value]) => {
202
- if (value.type === "positional") return acc;
203
- let key = makeShortLongOptionPair(value, name);
204
- if (value.type !== "boolean") key = value.default ? `${key} [${name}]` : `${key} <${name}>`;
202
+ return Object.entries(ctx.args).reduce((acc, [name, schema]) => {
203
+ if (schema.type === "positional") return acc;
204
+ let key = makeShortLongOptionPair(schema, name, ctx.toKebab);
205
+ if (schema.type !== "boolean") {
206
+ const displayName = ctx.toKebab || schema.toKebab ? kebabnize(name) : name;
207
+ key = schema.default ? `${key} [${displayName}]` : `${key} <${displayName}>`;
208
+ }
205
209
  acc[name] = key;
206
- if (value.type === "boolean" && value.negatable && !COMMON_ARGS_KEYS.includes(name)) acc[`no-${name}`] = `--no-${name}`;
210
+ if (schema.type === "boolean" && schema.negatable && !COMMON_ARGS_KEYS.includes(name)) {
211
+ const displayName = ctx.toKebab || schema.toKebab ? kebabnize(name) : name;
212
+ acc[`no-${name}`] = `--no-${displayName}`;
213
+ }
207
214
  return acc;
208
215
  }, create());
209
216
  }
@@ -217,7 +224,7 @@ function generateDefaultDisplayValue(ctx, schema) {
217
224
  function resolveDisplayValue(ctx, key) {
218
225
  if (COMMON_ARGS_KEYS.includes(key)) return "";
219
226
  const schema = ctx.args[key];
220
- if ((schema.type === "boolean" || schema.type === "number" || schema.type === "string") && schema.default !== void 0) return `(${generateDefaultDisplayValue(ctx, schema)})`;
227
+ if ((schema.type === "boolean" || schema.type === "number" || schema.type === "string" || schema.type === "custom") && schema.default !== void 0) return `(${generateDefaultDisplayValue(ctx, schema)})`;
221
228
  if (schema.type === "enum") {
222
229
  const _default = schema.default !== void 0 ? generateDefaultDisplayValue(ctx, schema) : "";
223
230
  const choices = `${ctx.translate(resolveBuiltInKey("CHOICES"))}: ${schema.choices.join(" | ")}`;
@@ -239,7 +246,7 @@ async function generateOptionalArgsUsage(ctx, optionsPairs) {
239
246
  if (!rawDesc && key.startsWith("no-")) {
240
247
  const name = resolveNegatableKey(key);
241
248
  const schema = ctx.args[name];
242
- const optionKey = makeShortLongOptionPair(schema, name);
249
+ const optionKey = makeShortLongOptionPair(schema, name, ctx.toKebab);
243
250
  rawDesc = `${ctx.translate(resolveBuiltInKey("NEGATABLE"))} ${optionKey}`;
244
251
  }
245
252
  const optionsSchema = ctx.env.usageOptionType ? `[${resolveNegatableType(key, ctx)}] ` : "";
package/lib/renderer.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CommandContext } from "./types-BDWiiycu.js";
1
+ import { CommandContext } from "./types-B7j6WSjQ.js";
2
2
  import { Args } from "args-tokens";
3
3
 
4
4
  //#region src/renderer/header.d.ts
package/lib/renderer.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./utils-D41C8Abf.js";
2
- import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-kzo45gaB.js";
1
+ import "./utils-B_QNzw5q.js";
2
+ import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-CTx2DsBI.js";
3
3
 
4
4
  export { renderHeader, renderUsage, renderValidationErrors };
@@ -271,6 +271,11 @@ interface CommandContext<A extends Args = Args, V = ArgValues<A>> {
271
271
  * The command call mode is `entry` when the command is executed as an entry command, and `subCommand` when the command is executed as a sub-command.
272
272
  */
273
273
  callMode: CommandCallMode;
274
+ /**
275
+ * Whether to convert the camel-case style argument name to kebab-case.
276
+ * This context value is set from {@link Command.toKebab} option.
277
+ */
278
+ toKebab?: boolean;
274
279
  /**
275
280
  * Output a message.
276
281
  * If {@link CommandEnvironment.usageSilent} is true, the message is not output.
@@ -324,6 +329,11 @@ interface Command<A extends Args = Args> {
324
329
  * Command resource fetcher.
325
330
  */
326
331
  resource?: CommandResourceFetcher<A>;
332
+ /**
333
+ * Whether to convert the camel-case style argument name to kebab-case.
334
+ * If you will set to `true`, All {@link Command.args} names will be converted to kebab-case.
335
+ */
336
+ toKebab?: boolean;
327
337
  }
328
338
  /**
329
339
  * Command resource.
@@ -72,6 +72,14 @@ async function resolveLazyCommand(cmd, name, needRunResolving = false) {
72
72
  function resolveBuiltInKey(key) {
73
73
  return `${BUILT_IN_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`;
74
74
  }
75
+ /**
76
+ * Convert a camelCase string to kebab-case
77
+ * @param str The string to convert
78
+ * @returns The kebab-case version of the string
79
+ */
80
+ function kebabnize(str) {
81
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
82
+ }
75
83
  function resolveArgKey(key) {
76
84
  return `${ARG_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`;
77
85
  }
@@ -100,4 +108,4 @@ function deepFreeze(obj) {
100
108
  }
101
109
 
102
110
  //#endregion
103
- export { ANONYMOUS_COMMAND_NAME, BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, DEFAULT_LOCALE as DEFAULT_LOCALE$1, NOOP, create, deepFreeze, isLazyCommand, log, mapResourceWithBuiltinKey, resolveArgKey, resolveBuiltInKey, resolveExamples, resolveLazyCommand };
111
+ export { ANONYMOUS_COMMAND_NAME, BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, DEFAULT_LOCALE as DEFAULT_LOCALE$1, NOOP, create, deepFreeze, isLazyCommand, kebabnize, log, mapResourceWithBuiltinKey, resolveArgKey, resolveBuiltInKey, resolveExamples, 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.23.1",
4
+ "version": "0.25.0",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -78,22 +78,23 @@
78
78
  }
79
79
  },
80
80
  "dependencies": {
81
- "args-tokens": "^0.17.1"
81
+ "args-tokens": "^0.19.0"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@eslint/markdown": "^6.4.0",
85
85
  "@intlify/core": "next",
86
86
  "@kazupon/eslint-config": "^0.29.0",
87
87
  "@kazupon/prettier-config": "^0.1.1",
88
- "@types/node": "^22.15.3",
89
- "@vitest/eslint-plugin": "^1.1.44",
90
- "bumpp": "^10.1.0",
91
- "deno": "^2.3.1",
92
- "eslint": "^9.26.0",
93
- "eslint-config-prettier": "^10.1.2",
94
- "eslint-import-resolver-typescript": "^4.3.4",
88
+ "@types/node": "^22.15.21",
89
+ "@typescript/native-preview": "7.0.0-dev.20250526.1",
90
+ "@vitest/eslint-plugin": "^1.2.1",
91
+ "bumpp": "^10.1.1",
92
+ "deno": "^2.3.3",
93
+ "eslint": "^9.27.0",
94
+ "eslint-config-prettier": "^10.1.5",
95
+ "eslint-import-resolver-typescript": "^4.4.1",
95
96
  "eslint-plugin-import": "^2.31.0",
96
- "eslint-plugin-jsonc": "^2.20.0",
97
+ "eslint-plugin-jsonc": "^2.20.1",
97
98
  "eslint-plugin-module-interop": "^0.3.1",
98
99
  "eslint-plugin-promise": "^7.2.1",
99
100
  "eslint-plugin-regexp": "^2.7.0",
@@ -103,27 +104,27 @@
103
104
  "eslint-plugin-vue-composable": "^1.0.0",
104
105
  "eslint-plugin-yml": "^1.18.0",
105
106
  "gh-changelogen": "^0.2.8",
106
- "gunshi019": "npm:gunshi@0.23.0",
107
+ "gunshi019": "npm:gunshi@0.19.0",
107
108
  "jsr": "^0.13.4",
108
- "jsr-exports-lint": "^0.2.0",
109
- "knip": "^5.53.0",
109
+ "jsr-exports-lint": "^0.4.0",
110
+ "knip": "^5.58.0",
110
111
  "lint-staged": "^16.0.0",
111
- "messageformat": "4.0.0-11",
112
+ "messageformat": "4.0.0-12",
112
113
  "mitata": "^1.0.34",
113
- "pkg-pr-new": "^0.0.43",
114
+ "pkg-pr-new": "^0.0.50",
114
115
  "prettier": "^3.5.3",
115
116
  "publint": "^0.3.12",
116
- "tsdown": "^0.10.2",
117
+ "tsdown": "^0.12.3",
117
118
  "typedoc": "^0.28.4",
118
119
  "typedoc-plugin-markdown": "^4.6.3",
119
120
  "typedoc-vitepress-theme": "^1.1.2",
120
- "typescript": "^5.8.3",
121
- "typescript-eslint": "^8.31.1",
121
+ "typescript-eslint": "^8.32.1",
122
122
  "vitepress": "^1.6.3",
123
- "vitepress-plugin-group-icons": "^1.5.2",
124
- "vitepress-plugin-llms": "^1.1.3",
125
- "vitest": "^3.1.2",
126
- "vue": "^3.5.13"
123
+ "vitepress-plugin-group-icons": "^1.5.5",
124
+ "vitepress-plugin-llms": "^1.3.4",
125
+ "vitest": "^3.1.4",
126
+ "vue": "^3.5.14",
127
+ "zod": "^3.25.28"
127
128
  },
128
129
  "prettier": "@kazupon/prettier-config",
129
130
  "lint-staged": {
@@ -167,6 +168,6 @@
167
168
  "test": "vitest --typecheck run",
168
169
  "typecheck": "pnpm run --stream --color \"/^typecheck:/\"",
169
170
  "typecheck:deno": "deno check --all ./src",
170
- "typecheck:tsc": "tsc --noEmit"
171
+ "typecheck:tsc": "tsgo --noEmit"
171
172
  }
172
173
  }