@clerc/plugin-help 0.13.0 → 0.13.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 +7 -4
- package/dist/index.mjs +7 -4
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { definePlugin, resolveCommand, NoSuchCommandError, SingleCommand } from '@clerc/core';
|
|
2
|
-
import { gracefulFlagName } from '@clerc/utils';
|
|
2
|
+
import { mustArray, gracefulFlagName } from '@clerc/utils';
|
|
3
3
|
import pc from 'picocolors';
|
|
4
4
|
import { Table } from '@clerc/toolkit';
|
|
5
5
|
|
|
@@ -101,7 +101,8 @@ const showHelp = (ctx, notes, examples) => {
|
|
|
101
101
|
sections.push({
|
|
102
102
|
title: "Commands:",
|
|
103
103
|
body: table(...Object.values(cli._commands).map((command) => {
|
|
104
|
-
|
|
104
|
+
const commandNameWithAlias = [command.name, ...mustArray(command.alias || [])].join(", ");
|
|
105
|
+
return [pc.cyan(commandNameWithAlias), DELIMITER, command.description];
|
|
105
106
|
})).toString().split("\n")
|
|
106
107
|
});
|
|
107
108
|
}
|
|
@@ -124,7 +125,7 @@ const showSubcommandHelp = (ctx, command) => {
|
|
|
124
125
|
throw new NoSuchCommandError(formatCommandName(command));
|
|
125
126
|
}
|
|
126
127
|
const sections = [];
|
|
127
|
-
generateCliDetail(sections, cli, subcommand);
|
|
128
|
+
generateCliDetail(sections, cli, ctx.isSingleCommand ? void 0 : subcommand);
|
|
128
129
|
const parameters = ((_a = subcommand.parameters) == null ? void 0 : _a.join(", ")) || "";
|
|
129
130
|
sections.push({
|
|
130
131
|
title: "Usage:",
|
|
@@ -191,7 +192,9 @@ const helpPlugin = ({
|
|
|
191
192
|
});
|
|
192
193
|
}
|
|
193
194
|
cli.inspector((ctx, next) => {
|
|
194
|
-
if (ctx.
|
|
195
|
+
if (!ctx.isSingleCommand && !ctx.raw._.length) {
|
|
196
|
+
showHelp(ctx, notes, examples);
|
|
197
|
+
} else if (ctx.raw.mergedFlags.h || ctx.raw.mergedFlags.help) {
|
|
195
198
|
if (ctx.raw._.length) {
|
|
196
199
|
showSubcommandHelp(ctx, ctx.raw._);
|
|
197
200
|
} else {
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { definePlugin, resolveCommand, NoSuchCommandError, SingleCommand } from '@clerc/core';
|
|
2
|
-
import { gracefulFlagName } from '@clerc/utils';
|
|
2
|
+
import { mustArray, gracefulFlagName } from '@clerc/utils';
|
|
3
3
|
import pc from 'picocolors';
|
|
4
4
|
import { Table } from '@clerc/toolkit';
|
|
5
5
|
|
|
@@ -101,7 +101,8 @@ const showHelp = (ctx, notes, examples) => {
|
|
|
101
101
|
sections.push({
|
|
102
102
|
title: "Commands:",
|
|
103
103
|
body: table(...Object.values(cli._commands).map((command) => {
|
|
104
|
-
|
|
104
|
+
const commandNameWithAlias = [command.name, ...mustArray(command.alias || [])].join(", ");
|
|
105
|
+
return [pc.cyan(commandNameWithAlias), DELIMITER, command.description];
|
|
105
106
|
})).toString().split("\n")
|
|
106
107
|
});
|
|
107
108
|
}
|
|
@@ -124,7 +125,7 @@ const showSubcommandHelp = (ctx, command) => {
|
|
|
124
125
|
throw new NoSuchCommandError(formatCommandName(command));
|
|
125
126
|
}
|
|
126
127
|
const sections = [];
|
|
127
|
-
generateCliDetail(sections, cli, subcommand);
|
|
128
|
+
generateCliDetail(sections, cli, ctx.isSingleCommand ? void 0 : subcommand);
|
|
128
129
|
const parameters = ((_a = subcommand.parameters) == null ? void 0 : _a.join(", ")) || "";
|
|
129
130
|
sections.push({
|
|
130
131
|
title: "Usage:",
|
|
@@ -191,7 +192,9 @@ const helpPlugin = ({
|
|
|
191
192
|
});
|
|
192
193
|
}
|
|
193
194
|
cli.inspector((ctx, next) => {
|
|
194
|
-
if (ctx.
|
|
195
|
+
if (!ctx.isSingleCommand && !ctx.raw._.length) {
|
|
196
|
+
showHelp(ctx, notes, examples);
|
|
197
|
+
} else if (ctx.raw.mergedFlags.h || ctx.raw.mergedFlags.help) {
|
|
195
198
|
if (ctx.raw._.length) {
|
|
196
199
|
showSubcommandHelp(ctx, ctx.raw._);
|
|
197
200
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/plugin-help",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"author": "Ray <nn_201312@163.com> (https://github.com/so1ve)",
|
|
5
5
|
"description": "Clerc plugin help",
|
|
6
6
|
"keywords": [
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"picocolors": "^1.0.0",
|
|
55
|
-
"@clerc/toolkit": "0.13.
|
|
56
|
-
"@clerc/utils": "0.13.
|
|
55
|
+
"@clerc/toolkit": "0.13.2",
|
|
56
|
+
"@clerc/utils": "0.13.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@clerc/core": "0.13.
|
|
59
|
+
"@clerc/core": "0.13.2"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "puild",
|