@gunshi/plugin-completion 0.29.3 → 0.29.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +13 -37
  2. package/package.json +11 -11
package/lib/index.js CHANGED
@@ -1,11 +1,9 @@
1
1
  /*! license ISC
2
- * @author Bombshell team and Bombshell contributors
3
- * Bombshell related codes are forked from @bombsh/tab
4
- */
5
-
2
+ * @author Bombshell team and Bombshell contributors
3
+ * Bombshell related codes are forked from @bombsh/tab
4
+ */
6
5
  import { RootCommand } from "@bomb.sh/tab";
7
6
  import { createCommandContext, plugin } from "@gunshi/plugin";
8
-
9
7
  //#region ../../node_modules/.pnpm/args-tokens@0.24.3/node_modules/args-tokens/lib/utils.js
10
8
  /**
11
9
  * Entry point of utils.
@@ -27,7 +25,6 @@ import { createCommandContext, plugin } from "@gunshi/plugin";
27
25
  function kebabnize(str) {
28
26
  return str.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase());
29
27
  }
30
-
31
28
  //#endregion
32
29
  //#region ../gunshi/src/utils.ts
33
30
  /**
@@ -106,21 +103,8 @@ function deepFreeze(obj, ignores = []) {
106
103
  }
107
104
  return Object.freeze(obj);
108
105
  }
109
-
110
- //#endregion
111
- //#region ../shared/src/constants.ts
112
- /**
113
- * @author kazuya kawaguchi (a.k.a. kazupon)
114
- * @license MIT
115
- */
116
- const BUILT_IN_PREFIX = "_";
117
- const PLUGIN_PREFIX = "g";
118
- const ARG_PREFIX = "arg";
119
- const BUILT_IN_KEY_SEPARATOR = ":";
120
- const BUILD_IN_PREFIX_AND_KEY_SEPARATOR = `${BUILT_IN_PREFIX}${BUILT_IN_KEY_SEPARATOR}`;
121
- const ARG_PREFIX_AND_KEY_SEPARATOR = `${ARG_PREFIX}${BUILT_IN_KEY_SEPARATOR}`;
122
- const ARG_NEGATABLE_PREFIX = "no-";
123
-
106
+ const BUILD_IN_PREFIX_AND_KEY_SEPARATOR = `_:`;
107
+ const ARG_PREFIX_AND_KEY_SEPARATOR = `arg:`;
124
108
  //#endregion
125
109
  //#region ../resources/locales/en-US.json
126
110
  var NEGATABLE = "Negatable of";
@@ -139,7 +123,6 @@ var en_US_default = {
139
123
  help: "Display this help message",
140
124
  version: "Display this version"
141
125
  };
142
-
143
126
  //#endregion
144
127
  //#region ../shared/src/utils.ts
145
128
  /**
@@ -159,7 +142,7 @@ var en_US_default = {
159
142
  * @returns Prefixed argument key.
160
143
  */
161
144
  function resolveArgKey(key, name) {
162
- return `${name ? `${name}${BUILT_IN_KEY_SEPARATOR}` : ""}${ARG_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`;
145
+ return `${name ? `${name}:` : ""}arg:${key}`;
163
146
  }
164
147
  /**
165
148
  * Resolve a namespaced key for non-built-in resources.
@@ -173,7 +156,7 @@ function resolveArgKey(key, name) {
173
156
  * @returns Prefixed non-built-in key.
174
157
  */
175
158
  function resolveKey(key, name) {
176
- return `${name ? `${name}${BUILT_IN_KEY_SEPARATOR}` : ""}${key}`;
159
+ return `${name ? `${name}:` : ""}${key}`;
177
160
  }
178
161
  /**
179
162
  * Resolve command examples.
@@ -196,7 +179,7 @@ async function resolveExamples(ctx, examples) {
196
179
  * @returns A namespaced key for the plugin.
197
180
  */
198
181
  function namespacedId(id) {
199
- return `${PLUGIN_PREFIX}${BUILT_IN_KEY_SEPARATOR}${id}`;
182
+ return `g:${id}`;
200
183
  }
201
184
  /**
202
185
  * Generate a short and long option pair for command arguments.
@@ -211,7 +194,6 @@ function makeShortLongOptionPair(schema, name, toKebab) {
211
194
  if (schema.short) key = `-${schema.short}, ${key}`;
212
195
  return key;
213
196
  }
214
-
215
197
  //#endregion
216
198
  //#region ../shared/src/localization.ts
217
199
  /**
@@ -240,8 +222,8 @@ function localizable(ctx, cmd, translate) {
240
222
  if (key.startsWith(namaspacedArgKey)) {
241
223
  let argKey = key.slice(namaspacedArgKey.length);
242
224
  let negatable = false;
243
- if (argKey.startsWith(ARG_NEGATABLE_PREFIX)) {
244
- argKey = argKey.slice(ARG_NEGATABLE_PREFIX.length);
225
+ if (argKey.startsWith("no-")) {
226
+ argKey = argKey.slice(3);
245
227
  negatable = true;
246
228
  }
247
229
  const schema = ctx.args[argKey];
@@ -254,7 +236,6 @@ function localizable(ctx, cmd, translate) {
254
236
  }
255
237
  return localize;
256
238
  }
257
-
258
239
  //#endregion
259
240
  //#region src/types.ts
260
241
  /**
@@ -265,7 +246,6 @@ function localizable(ctx, cmd, translate) {
265
246
  * The unique identifier for the completion plugin.
266
247
  */
267
248
  const pluginId = namespacedId("completion");
268
-
269
249
  //#endregion
270
250
  //#region src/utils.ts
271
251
  /**
@@ -300,7 +280,6 @@ function quoteExec() {
300
280
  default: throw new Error("Unsupported your javascript runtime for completion script generation.");
301
281
  }
302
282
  }
303
-
304
283
  //#endregion
305
284
  //#region src/index.ts
306
285
  /**
@@ -404,14 +383,12 @@ function completion(options = {}) {
404
383
  }
405
384
  });
406
385
  },
407
- onExtension: async (ctx) => {
386
+ onExtension: async (ctx, cmd) => {
408
387
  const i18n = ctx.extensions[i18nPluginId];
409
388
  const subCommands = ctx.env.subCommands;
410
- const entry = [...subCommands].map(([_, cmd]) => cmd).find((cmd) => cmd.entry);
411
- if (!entry) throw new Error("entry command not found.");
412
389
  await registerCompletion({
413
390
  name: "entry",
414
- cmd: entry,
391
+ cmd: [...subCommands].map(([_, cmd]) => cmd).find((cmd) => cmd.entry) || cmd,
415
392
  config,
416
393
  i18nPluginId,
417
394
  i18n,
@@ -478,6 +455,5 @@ function getNestedSubCommands(cmd) {
478
455
  return map;
479
456
  }
480
457
  }
481
-
482
458
  //#endregion
483
- export { completion as default, pluginId };
459
+ export { completion as default, pluginId };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gunshi/plugin-completion",
3
3
  "description": "completion plugin for gunshi",
4
- "version": "0.29.3",
4
+ "version": "0.29.5",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -52,24 +52,24 @@
52
52
  }
53
53
  },
54
54
  "dependencies": {
55
- "@bomb.sh/tab": "^0.0.11",
56
- "@gunshi/plugin": "0.29.3"
55
+ "@bomb.sh/tab": "^0.0.14",
56
+ "@gunshi/plugin": "0.29.5"
57
57
  },
58
58
  "peerDependencies": {
59
- "@gunshi/plugin-i18n": "0.29.3"
59
+ "@gunshi/plugin-i18n": "0.29.5"
60
60
  },
61
61
  "devDependencies": {
62
- "@types/node": "^25.4.0",
63
- "deno": "^2.7.4",
64
- "jsr": "^0.13.5",
62
+ "@types/node": "^25.5.2",
63
+ "deno": "^2.7.11",
64
+ "jsr": "^0.14.3",
65
65
  "jsr-exports-lint": "^0.4.2",
66
66
  "publint": "^0.3.18",
67
67
  "rollup-plugin-license": "^3.6.0",
68
68
  "tsdown": "0.15.12",
69
- "typedoc": "^0.28.17",
70
- "typedoc-plugin-markdown": "^4.10.0",
71
- "@gunshi/shared": "0.29.3",
72
- "@gunshi/plugin-i18n": "0.29.3"
69
+ "typedoc": "^0.28.18",
70
+ "typedoc-plugin-markdown": "^4.11.0",
71
+ "@gunshi/plugin-i18n": "0.29.5",
72
+ "@gunshi/shared": "0.29.5"
73
73
  },
74
74
  "scripts": {
75
75
  "build": "tsdown",