@clerc/plugin-help 1.0.0-beta.17 → 1.0.0-beta.18
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 +16 -4
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NoSuchCommandError, definePlugin, resolveCommand } from "@clerc/core";
|
|
1
|
+
import { NoSuchCommandError, definePlugin, normalizeFlagValue, resolveCommand } from "@clerc/core";
|
|
2
2
|
import stringWidth from "string-width";
|
|
3
3
|
import textTable from "text-table";
|
|
4
4
|
import * as yc from "yoctocolors";
|
|
@@ -111,11 +111,11 @@ var HelpRenderer = class {
|
|
|
111
111
|
title: "Parameters",
|
|
112
112
|
body: splitTable(command.parameters.map((parameter) => {
|
|
113
113
|
const key = typeof parameter === "string" ? parameter : parameter.key;
|
|
114
|
-
const
|
|
114
|
+
const type = typeof parameter === "string" ? void 0 : parameter.type;
|
|
115
115
|
const description = typeof parameter === "string" ? void 0 : parameter.description;
|
|
116
116
|
return [
|
|
117
117
|
yc.blue(key),
|
|
118
|
-
|
|
118
|
+
type?.display ? yc.gray(type.display) : void 0,
|
|
119
119
|
description
|
|
120
120
|
].filter(isTruthy);
|
|
121
121
|
}))
|
|
@@ -177,6 +177,7 @@ var HelpRenderer = class {
|
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
renderFlagItem(name, flag) {
|
|
180
|
+
flag = normalizeFlagValue(flag);
|
|
180
181
|
const flagName = formatFlagName(name);
|
|
181
182
|
const aliases = (Array.isArray(flag.alias) ? flag.alias : flag.alias ? [flag.alias] : []).map(formatFlagName).join(", ");
|
|
182
183
|
const type = this._formatters.formatFlagType(flag.type);
|
|
@@ -249,9 +250,20 @@ var HelpRenderer = class {
|
|
|
249
250
|
}
|
|
250
251
|
};
|
|
251
252
|
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region src/store.ts
|
|
255
|
+
function addStoreApi(cli, { groups }) {
|
|
256
|
+
cli.store.help = { addGroup: (options) => {
|
|
257
|
+
if (options.commands) groups.commands = [...groups.commands ?? [], ...options.commands];
|
|
258
|
+
if (options.flags) groups.flags = [...groups.flags ?? [], ...options.flags];
|
|
259
|
+
if (options.globalFlags) groups.globalFlags = [...groups.globalFlags ?? [], ...options.globalFlags];
|
|
260
|
+
} };
|
|
261
|
+
}
|
|
262
|
+
|
|
252
263
|
//#endregion
|
|
253
264
|
//#region src/index.ts
|
|
254
|
-
const helpPlugin = ({ command = true, flag = true, showHelpWhenNoCommandSpecified = true, notes, examples, banner, formatters, groups } = {}) => definePlugin({ setup: (cli) => {
|
|
265
|
+
const helpPlugin = ({ command = true, flag = true, showHelpWhenNoCommandSpecified = true, notes, examples, banner, formatters, groups = {} } = {}) => definePlugin({ setup: (cli) => {
|
|
266
|
+
addStoreApi(cli, { groups });
|
|
255
267
|
const mergedFormatters = {
|
|
256
268
|
...defaultFormatters,
|
|
257
269
|
...formatters
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/plugin-help",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.18",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clerc plugin help",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"kons": "^0.7.1",
|
|
55
|
-
"@clerc/
|
|
56
|
-
"@clerc/
|
|
57
|
-
"@clerc/parser": "1.0.0-beta.
|
|
55
|
+
"@clerc/utils": "1.0.0-beta.18",
|
|
56
|
+
"@clerc/core": "1.0.0-beta.18",
|
|
57
|
+
"@clerc/parser": "1.0.0-beta.18"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@clerc/core": "*"
|