@clerc/plugin-help 0.12.0 → 0.12.2

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/dist/index.js CHANGED
@@ -62,7 +62,7 @@ const generateCliDetail = (sections, cli, subcommand) => {
62
62
  if (subcommand) {
63
63
  items.push({
64
64
  title: pc.gray("Subcommand:"),
65
- body: pc.green(subcommand)
65
+ body: pc.green(subcommand.name)
66
66
  });
67
67
  }
68
68
  sections.push({
@@ -71,7 +71,7 @@ const generateCliDetail = (sections, cli, subcommand) => {
71
71
  });
72
72
  sections.push({
73
73
  title: "Description:",
74
- body: [cli._description]
74
+ body: [(subcommand == null ? void 0 : subcommand.description) || cli._description]
75
75
  });
76
76
  };
77
77
  const generateExamples = (sections, examples) => {
@@ -123,7 +123,7 @@ const showSubcommandHelp = (ctx, command) => {
123
123
  throw new NoSuchCommandError(command.join(" "));
124
124
  }
125
125
  const sections = [];
126
- generateCliDetail(sections, cli, subcommand.name);
126
+ generateCliDetail(sections, cli, subcommand);
127
127
  const parameters = ((_a = subcommand.parameters) == null ? void 0 : _a.join(", ")) || "";
128
128
  sections.push({
129
129
  title: "Usage:",
@@ -166,41 +166,36 @@ const helpPlugin = ({
166
166
  examples
167
167
  } = {}) => definePlugin({
168
168
  setup: (cli) => {
169
- cli = cli.inspector({
170
- enforce: "post",
171
- fn: (ctx, next) => {
172
- if (command && !ctx.isSingleCommand) {
173
- cli = cli.command("help", "Show help", {
174
- parameters: [
175
- "[command...]"
176
- ],
177
- notes: [
178
- "If no command is specified, show help for the CLI.",
179
- "If a command is specified, show help for the command.",
180
- "-h is an alias for --help."
181
- ],
182
- examples: [
183
- [`$ ${cli._name} help`, "Show help"],
184
- [`$ ${cli._name} help <command>`, "Show help for a specific command"],
185
- [`$ ${cli._name} <command> --help`, "Show help for a specific command"]
186
- ]
187
- }).on("help", (ctx2) => {
188
- if (ctx2.parameters.command.length) {
189
- showSubcommandHelp(ctx2, ctx2.parameters.command);
190
- } else {
191
- showHelp(ctx2, notes, examples);
192
- }
193
- });
169
+ if (command) {
170
+ cli = cli.command("help", "Show help", {
171
+ parameters: [
172
+ "[command...]"
173
+ ],
174
+ notes: [
175
+ "If no command is specified, show help for the CLI.",
176
+ "If a command is specified, show help for the command.",
177
+ "-h is an alias for --help."
178
+ ],
179
+ examples: [
180
+ [`$ ${cli._name} help`, "Show help"],
181
+ [`$ ${cli._name} help <command>`, "Show help for a specific command"],
182
+ [`$ ${cli._name} <command> --help`, "Show help for a specific command"]
183
+ ]
184
+ }).on("help", (ctx) => {
185
+ if (ctx.parameters.command.length) {
186
+ showSubcommandHelp(ctx, ctx.parameters.command);
187
+ } else {
188
+ showHelp(ctx, notes, examples);
194
189
  }
195
- if (ctx.raw.mergedFlags.h || ctx.raw.mergedFlags.help) {
196
- if (ctx.raw._.length) {
197
- showSubcommandHelp(ctx, ctx.raw._);
198
- } else {
199
- showHelp(ctx, notes, examples);
200
- }
201
- return;
190
+ });
191
+ }
192
+ cli.inspector((ctx) => {
193
+ if (ctx.raw.mergedFlags.h || ctx.raw.mergedFlags.help) {
194
+ if (ctx.raw._.length) {
195
+ showSubcommandHelp(ctx, ctx.raw._);
196
+ } else {
197
+ showHelp(ctx, notes, examples);
202
198
  }
203
- next();
204
199
  }
205
200
  });
206
201
  return cli;
package/dist/index.mjs CHANGED
@@ -62,7 +62,7 @@ const generateCliDetail = (sections, cli, subcommand) => {
62
62
  if (subcommand) {
63
63
  items.push({
64
64
  title: pc.gray("Subcommand:"),
65
- body: pc.green(subcommand)
65
+ body: pc.green(subcommand.name)
66
66
  });
67
67
  }
68
68
  sections.push({
@@ -71,7 +71,7 @@ const generateCliDetail = (sections, cli, subcommand) => {
71
71
  });
72
72
  sections.push({
73
73
  title: "Description:",
74
- body: [cli._description]
74
+ body: [(subcommand == null ? void 0 : subcommand.description) || cli._description]
75
75
  });
76
76
  };
77
77
  const generateExamples = (sections, examples) => {
@@ -123,7 +123,7 @@ const showSubcommandHelp = (ctx, command) => {
123
123
  throw new NoSuchCommandError(command.join(" "));
124
124
  }
125
125
  const sections = [];
126
- generateCliDetail(sections, cli, subcommand.name);
126
+ generateCliDetail(sections, cli, subcommand);
127
127
  const parameters = ((_a = subcommand.parameters) == null ? void 0 : _a.join(", ")) || "";
128
128
  sections.push({
129
129
  title: "Usage:",
@@ -166,41 +166,36 @@ const helpPlugin = ({
166
166
  examples
167
167
  } = {}) => definePlugin({
168
168
  setup: (cli) => {
169
- cli = cli.inspector({
170
- enforce: "post",
171
- fn: (ctx, next) => {
172
- if (command && !ctx.isSingleCommand) {
173
- cli = cli.command("help", "Show help", {
174
- parameters: [
175
- "[command...]"
176
- ],
177
- notes: [
178
- "If no command is specified, show help for the CLI.",
179
- "If a command is specified, show help for the command.",
180
- "-h is an alias for --help."
181
- ],
182
- examples: [
183
- [`$ ${cli._name} help`, "Show help"],
184
- [`$ ${cli._name} help <command>`, "Show help for a specific command"],
185
- [`$ ${cli._name} <command> --help`, "Show help for a specific command"]
186
- ]
187
- }).on("help", (ctx2) => {
188
- if (ctx2.parameters.command.length) {
189
- showSubcommandHelp(ctx2, ctx2.parameters.command);
190
- } else {
191
- showHelp(ctx2, notes, examples);
192
- }
193
- });
169
+ if (command) {
170
+ cli = cli.command("help", "Show help", {
171
+ parameters: [
172
+ "[command...]"
173
+ ],
174
+ notes: [
175
+ "If no command is specified, show help for the CLI.",
176
+ "If a command is specified, show help for the command.",
177
+ "-h is an alias for --help."
178
+ ],
179
+ examples: [
180
+ [`$ ${cli._name} help`, "Show help"],
181
+ [`$ ${cli._name} help <command>`, "Show help for a specific command"],
182
+ [`$ ${cli._name} <command> --help`, "Show help for a specific command"]
183
+ ]
184
+ }).on("help", (ctx) => {
185
+ if (ctx.parameters.command.length) {
186
+ showSubcommandHelp(ctx, ctx.parameters.command);
187
+ } else {
188
+ showHelp(ctx, notes, examples);
194
189
  }
195
- if (ctx.raw.mergedFlags.h || ctx.raw.mergedFlags.help) {
196
- if (ctx.raw._.length) {
197
- showSubcommandHelp(ctx, ctx.raw._);
198
- } else {
199
- showHelp(ctx, notes, examples);
200
- }
201
- return;
190
+ });
191
+ }
192
+ cli.inspector((ctx) => {
193
+ if (ctx.raw.mergedFlags.h || ctx.raw.mergedFlags.help) {
194
+ if (ctx.raw._.length) {
195
+ showSubcommandHelp(ctx, ctx.raw._);
196
+ } else {
197
+ showHelp(ctx, notes, examples);
202
198
  }
203
- next();
204
199
  }
205
200
  });
206
201
  return cli;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerc/plugin-help",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "author": "Ray <nn_201312@163.com> (https://github.com/so1ve)",
5
5
  "description": "Clerc plugin help",
6
6
  "keywords": [
@@ -51,12 +51,12 @@
51
51
  "@clerc/core": "*"
52
52
  },
53
53
  "dependencies": {
54
- "@clerc/toolkit": "0.12.0",
55
- "@clerc/utils": "0.12.0",
56
- "picocolors": "^1.0.0"
54
+ "picocolors": "^1.0.0",
55
+ "@clerc/toolkit": "0.12.2",
56
+ "@clerc/utils": "0.12.2"
57
57
  },
58
58
  "devDependencies": {
59
- "@clerc/core": "0.12.0"
59
+ "@clerc/core": "0.12.2"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "puild",