@clerc/plugin-help 0.17.1 → 0.17.3
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 +23 -18
- package/dist/index.mjs +23 -18
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -27,6 +27,9 @@ const table = (...items) => {
|
|
|
27
27
|
table2.push(...items);
|
|
28
28
|
return table2;
|
|
29
29
|
};
|
|
30
|
+
const splitTable = (...items) => {
|
|
31
|
+
return table(...items).toString().split("\n");
|
|
32
|
+
};
|
|
30
33
|
|
|
31
34
|
const render = (sections) => {
|
|
32
35
|
const rendered = [];
|
|
@@ -79,7 +82,7 @@ const generateExamples = (sections, examples) => {
|
|
|
79
82
|
const examplesFormatted = examples.map(([command, description]) => [command, DELIMITER, description]);
|
|
80
83
|
sections.push({
|
|
81
84
|
title: "Examples:",
|
|
82
|
-
body:
|
|
85
|
+
body: splitTable(...examplesFormatted)
|
|
83
86
|
});
|
|
84
87
|
};
|
|
85
88
|
const showHelp = (ctx, notes, examples) => {
|
|
@@ -100,10 +103,10 @@ const showHelp = (ctx, notes, examples) => {
|
|
|
100
103
|
if (!ctx.isSingleCommand) {
|
|
101
104
|
sections.push({
|
|
102
105
|
title: "Commands:",
|
|
103
|
-
body:
|
|
106
|
+
body: splitTable(...Object.values(cli._commands).map((command) => {
|
|
104
107
|
const commandNameWithAlias = [command.name, ...mustArray(command.alias || [])].join(", ");
|
|
105
108
|
return [pc.cyan(commandNameWithAlias), DELIMITER, command.description];
|
|
106
|
-
}))
|
|
109
|
+
}))
|
|
107
110
|
});
|
|
108
111
|
}
|
|
109
112
|
if (notes) {
|
|
@@ -134,21 +137,23 @@ const showSubcommandHelp = (ctx, command) => {
|
|
|
134
137
|
if (subcommand.flags) {
|
|
135
138
|
sections.push({
|
|
136
139
|
title: "Flags:",
|
|
137
|
-
body:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
140
|
+
body: splitTable(
|
|
141
|
+
...Object.entries(subcommand.flags).map(([name, flag]) => {
|
|
142
|
+
const flagNameWithAlias = [gracefulFlagName(name)];
|
|
143
|
+
if (flag.alias) {
|
|
144
|
+
flagNameWithAlias.push(gracefulFlagName(flag.alias));
|
|
145
|
+
}
|
|
146
|
+
const items = [pc.blue(flagNameWithAlias.join(", "))];
|
|
147
|
+
if (flag.description) {
|
|
148
|
+
items.push(DELIMITER, flag.description);
|
|
149
|
+
}
|
|
150
|
+
if (flag.type) {
|
|
151
|
+
const type = Array.isArray(flag.type) ? `Array<${flag.type[0].name}>` : flag.type.name;
|
|
152
|
+
items.push(pc.gray(`(${type})`));
|
|
153
|
+
}
|
|
154
|
+
return items;
|
|
155
|
+
})
|
|
156
|
+
)
|
|
152
157
|
});
|
|
153
158
|
}
|
|
154
159
|
if (subcommand.notes) {
|
package/dist/index.mjs
CHANGED
|
@@ -27,6 +27,9 @@ const table = (...items) => {
|
|
|
27
27
|
table2.push(...items);
|
|
28
28
|
return table2;
|
|
29
29
|
};
|
|
30
|
+
const splitTable = (...items) => {
|
|
31
|
+
return table(...items).toString().split("\n");
|
|
32
|
+
};
|
|
30
33
|
|
|
31
34
|
const render = (sections) => {
|
|
32
35
|
const rendered = [];
|
|
@@ -79,7 +82,7 @@ const generateExamples = (sections, examples) => {
|
|
|
79
82
|
const examplesFormatted = examples.map(([command, description]) => [command, DELIMITER, description]);
|
|
80
83
|
sections.push({
|
|
81
84
|
title: "Examples:",
|
|
82
|
-
body:
|
|
85
|
+
body: splitTable(...examplesFormatted)
|
|
83
86
|
});
|
|
84
87
|
};
|
|
85
88
|
const showHelp = (ctx, notes, examples) => {
|
|
@@ -100,10 +103,10 @@ const showHelp = (ctx, notes, examples) => {
|
|
|
100
103
|
if (!ctx.isSingleCommand) {
|
|
101
104
|
sections.push({
|
|
102
105
|
title: "Commands:",
|
|
103
|
-
body:
|
|
106
|
+
body: splitTable(...Object.values(cli._commands).map((command) => {
|
|
104
107
|
const commandNameWithAlias = [command.name, ...mustArray(command.alias || [])].join(", ");
|
|
105
108
|
return [pc.cyan(commandNameWithAlias), DELIMITER, command.description];
|
|
106
|
-
}))
|
|
109
|
+
}))
|
|
107
110
|
});
|
|
108
111
|
}
|
|
109
112
|
if (notes) {
|
|
@@ -134,21 +137,23 @@ const showSubcommandHelp = (ctx, command) => {
|
|
|
134
137
|
if (subcommand.flags) {
|
|
135
138
|
sections.push({
|
|
136
139
|
title: "Flags:",
|
|
137
|
-
body:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
140
|
+
body: splitTable(
|
|
141
|
+
...Object.entries(subcommand.flags).map(([name, flag]) => {
|
|
142
|
+
const flagNameWithAlias = [gracefulFlagName(name)];
|
|
143
|
+
if (flag.alias) {
|
|
144
|
+
flagNameWithAlias.push(gracefulFlagName(flag.alias));
|
|
145
|
+
}
|
|
146
|
+
const items = [pc.blue(flagNameWithAlias.join(", "))];
|
|
147
|
+
if (flag.description) {
|
|
148
|
+
items.push(DELIMITER, flag.description);
|
|
149
|
+
}
|
|
150
|
+
if (flag.type) {
|
|
151
|
+
const type = Array.isArray(flag.type) ? `Array<${flag.type[0].name}>` : flag.type.name;
|
|
152
|
+
items.push(pc.gray(`(${type})`));
|
|
153
|
+
}
|
|
154
|
+
return items;
|
|
155
|
+
})
|
|
156
|
+
)
|
|
152
157
|
});
|
|
153
158
|
}
|
|
154
159
|
if (subcommand.notes) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/plugin-help",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.3",
|
|
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.17.
|
|
56
|
-
"@clerc/utils": "0.17.
|
|
55
|
+
"@clerc/toolkit": "0.17.3",
|
|
56
|
+
"@clerc/utils": "0.17.3"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@clerc/core": "0.17.
|
|
59
|
+
"@clerc/core": "0.17.3"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "puild",
|