@clerc/plugin-help 1.0.0-beta.25 → 1.0.0-beta.27
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 +11 -9
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NoSuchCommandError, definePlugin, normalizeFlagValue, resolveCommand } from "@clerc/core";
|
|
1
|
+
import { DOUBLE_DASH, 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";
|
|
@@ -112,8 +112,8 @@ var HelpRenderer = class {
|
|
|
112
112
|
if (command) {
|
|
113
113
|
if (command.name) usage += ` ${command.name}`;
|
|
114
114
|
if (command.parameters) usage += ` ${command.parameters.map((p) => typeof p === "string" ? p : p.key).join(" ")}`;
|
|
115
|
-
} else if (this._cli._commands.size > 0 && !(this._cli._commands.has("") && this._cli._commands.size === 1)) usage += this._cli._commands.has("") ? "
|
|
116
|
-
if (command?.flags && !objectIsEmpty(command.flags) || !objectIsEmpty(this._globalFlags)) usage += "
|
|
115
|
+
} else if (this._cli._commands.size > 0 && !(this._cli._commands.has("") && this._cli._commands.size === 1)) usage += this._cli._commands.has("") ? ` ${yc.dim("[command]")}` : ` ${yc.dim("<command>")}`;
|
|
116
|
+
if (command?.flags && !objectIsEmpty(command.flags) || !objectIsEmpty(this._globalFlags)) usage += ` ${yc.dim("[flags]")}`;
|
|
117
117
|
return {
|
|
118
118
|
title: "Usage",
|
|
119
119
|
body: [usage]
|
|
@@ -124,13 +124,14 @@ var HelpRenderer = class {
|
|
|
124
124
|
if (!command?.parameters || command.parameters.length === 0) return;
|
|
125
125
|
return {
|
|
126
126
|
title: "Parameters",
|
|
127
|
-
body: splitTable(command.parameters.map((parameter) => {
|
|
127
|
+
body: splitTable(command.parameters.filter((p) => p !== DOUBLE_DASH).map((parameter) => {
|
|
128
128
|
const key = typeof parameter === "string" ? parameter : parameter.key;
|
|
129
129
|
const type = typeof parameter === "string" ? void 0 : parameter.type;
|
|
130
|
+
const formattedType = type ? this._formatters.formatTypeValue(type) : "string";
|
|
130
131
|
const description = typeof parameter === "string" ? void 0 : parameter.description;
|
|
131
132
|
return [
|
|
132
133
|
yc.bold(key),
|
|
133
|
-
|
|
134
|
+
yc.dim(formattedType),
|
|
134
135
|
description
|
|
135
136
|
].filter(isTruthy);
|
|
136
137
|
}))
|
|
@@ -209,14 +210,15 @@ var HelpRenderer = class {
|
|
|
209
210
|
}
|
|
210
211
|
renderFlagItem(name, flag) {
|
|
211
212
|
flag = normalizeFlagValue(flag);
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
let flagName = formatFlagName(name);
|
|
214
|
+
if (flag.short) flagName += `, ${formatFlagName(flag.short)}`;
|
|
214
215
|
const type = this._formatters.formatTypeValue(flag.type);
|
|
216
|
+
const default_ = flag.default !== void 0 && yc.dim(`[default: ${yc.bold(this._formatters.formatFlagDefault(flag.default))}]`);
|
|
215
217
|
return [
|
|
216
|
-
yc.bold(
|
|
218
|
+
yc.bold(flagName),
|
|
217
219
|
yc.dim(type),
|
|
218
220
|
flag.description,
|
|
219
|
-
|
|
221
|
+
default_
|
|
220
222
|
].filter(isTruthy);
|
|
221
223
|
}
|
|
222
224
|
renderGroupedFlags(flags, groupMap, itemType) {
|
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.27",
|
|
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/
|
|
55
|
+
"@clerc/core": "1.0.0-beta.27",
|
|
56
|
+
"@clerc/utils": "1.0.0-beta.27",
|
|
57
|
+
"@clerc/parser": "1.0.0-beta.27"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@clerc/core": "*"
|