@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 +31 -36
- package/dist/index.mjs +31 -36
- package/package.json +5 -5
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
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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.
|
|
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
|
-
"
|
|
55
|
-
"@clerc/
|
|
56
|
-
"
|
|
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.
|
|
59
|
+
"@clerc/core": "0.12.2"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "puild",
|