@gunshi/plugin-renderer 0.27.6 → 0.28.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.
Files changed (2) hide show
  1. package/lib/index.js +7 -3
  2. package/package.json +4 -4
package/lib/index.js CHANGED
@@ -50,7 +50,8 @@ async function resolveLazyCommand(cmd, name, needRunResolving = false) {
50
50
  args: cmd.args,
51
51
  examples: cmd.examples,
52
52
  internal: cmd.internal,
53
- entry: cmd.entry
53
+ entry: cmd.entry,
54
+ subCommands: cmd.subCommands
54
55
  };
55
56
  if ("resource" in cmd && cmd.resource) baseCommand.resource = cmd.resource;
56
57
  command = Object.assign(create(), baseCommand);
@@ -66,6 +67,7 @@ async function resolveLazyCommand(cmd, name, needRunResolving = false) {
66
67
  command.examples = loaded.examples;
67
68
  command.internal = loaded.internal;
68
69
  command.entry = loaded.entry;
70
+ command.subCommands = loaded.subCommands || cmd.subCommands;
69
71
  if ("resource" in loaded && loaded.resource) command.resource = loaded.resource;
70
72
  } else throw new TypeError(`Cannot resolve command: ${cmd.name || name}`);
71
73
  }
@@ -311,7 +313,7 @@ const COMMON_ARGS_KEYS = Object.keys(COMMON_ARGS);
311
313
  */
312
314
  async function renderUsage(ctx) {
313
315
  const messages = [];
314
- if (!ctx.omitted) {
316
+ if (ctx.callMode === "subCommand") {
315
317
  const description = await resolveDescription(ctx);
316
318
  if (description) messages.push(description, "");
317
319
  }
@@ -405,10 +407,11 @@ async function renderCommandsSection(ctx) {
405
407
  return `${command.padStart(ctx.env.leftMargin + command.length)}`;
406
408
  }));
407
409
  messages.push(...commandsStr, "", `${await ctx.extensions[pluginId].text(resolveBuiltInKey("FORMORE"))}:`);
410
+ const basePath = ctx.commandPath && ctx.commandPath.length > 0 ? `${ctx.env.name} ${ctx.commandPath.join(" ")}` : ctx.env.name;
408
411
  messages.push(...loadedCommands.map((cmd) => {
409
412
  let commandStr = cmd.entry ? "" : cmd.name || "";
410
413
  if (commandStr) commandStr += " ";
411
- const commandHelp = `${ctx.env.name} ${commandStr}--help`;
414
+ const commandHelp = `${basePath} ${commandStr}--help`;
412
415
  return `${commandHelp.padStart(ctx.env.leftMargin + commandHelp.length)}`;
413
416
  }));
414
417
  return messages;
@@ -443,6 +446,7 @@ async function resolveEntry(ctx) {
443
446
  * @returns The sub command name
444
447
  */
445
448
  async function resolveSubCommand(ctx) {
449
+ if (ctx.commandPath && ctx.commandPath.length > 0) return ctx.commandPath.join(" ");
446
450
  return ctx.name || await ctx.extensions[pluginId].text(resolveBuiltInKey("SUBCOMMAND"));
447
451
  }
448
452
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gunshi/plugin-renderer",
3
3
  "description": "usage renderer plugin for gunshi",
4
- "version": "0.27.6",
4
+ "version": "0.28.0",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -53,10 +53,10 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@gunshi/plugin": "0.27.6"
56
+ "@gunshi/plugin": "0.28.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "@gunshi/plugin-i18n": "0.27.6"
59
+ "@gunshi/plugin-i18n": "0.28.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "deno": "^2.6.3",
@@ -66,7 +66,7 @@
66
66
  "tsdown": "0.15.12",
67
67
  "typedoc": "^0.28.15",
68
68
  "typedoc-plugin-markdown": "^4.9.0",
69
- "@gunshi/shared": "0.27.6"
69
+ "@gunshi/shared": "0.28.0"
70
70
  },
71
71
  "scripts": {
72
72
  "build": "tsdown",