@clerc/plugin-completions 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 +20 -16
- package/package.json +6 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import t from "@bomb.sh/tab";
|
|
2
|
-
import { Clerc, NoCommandSpecifiedError, NoSuchCommandError, Types, definePlugin, normalizeFlagValue, resolveCommand } from "@clerc/core";
|
|
2
|
+
import { Clerc, DOUBLE_DASH, NoCommandSpecifiedError, NoSuchCommandError, Types, definePlugin, normalizeFlagValue, resolveCommand } from "@clerc/core";
|
|
3
3
|
import tty from "node:tty";
|
|
4
4
|
|
|
5
5
|
//#region rolldown:runtime
|
|
@@ -384,8 +384,8 @@ var HelpRenderer = class {
|
|
|
384
384
|
if (command) {
|
|
385
385
|
if (command.name) usage += ` ${command.name}`;
|
|
386
386
|
if (command.parameters) usage += ` ${command.parameters.map((p$1) => typeof p$1 === "string" ? p$1 : p$1.key).join(" ")}`;
|
|
387
|
-
} else if (this._cli._commands.size > 0 && !(this._cli._commands.has("") && this._cli._commands.size === 1)) usage += this._cli._commands.has("") ? "
|
|
388
|
-
if (command?.flags && !objectIsEmpty(command.flags) || !objectIsEmpty(this._globalFlags)) usage += "
|
|
387
|
+
} else if (this._cli._commands.size > 0 && !(this._cli._commands.has("") && this._cli._commands.size === 1)) usage += this._cli._commands.has("") ? ` ${dim("[command]")}` : ` ${dim("<command>")}`;
|
|
388
|
+
if (command?.flags && !objectIsEmpty(command.flags) || !objectIsEmpty(this._globalFlags)) usage += ` ${dim("[flags]")}`;
|
|
389
389
|
return {
|
|
390
390
|
title: "Usage",
|
|
391
391
|
body: [usage]
|
|
@@ -396,13 +396,14 @@ var HelpRenderer = class {
|
|
|
396
396
|
if (!command?.parameters || command.parameters.length === 0) return;
|
|
397
397
|
return {
|
|
398
398
|
title: "Parameters",
|
|
399
|
-
body: splitTable(command.parameters.map((parameter) => {
|
|
399
|
+
body: splitTable(command.parameters.filter((p$1) => p$1 !== DOUBLE_DASH).map((parameter) => {
|
|
400
400
|
const key = typeof parameter === "string" ? parameter : parameter.key;
|
|
401
401
|
const type = typeof parameter === "string" ? void 0 : parameter.type;
|
|
402
|
+
const formattedType = type ? this._formatters.formatTypeValue(type) : "string";
|
|
402
403
|
const description = typeof parameter === "string" ? void 0 : parameter.description;
|
|
403
404
|
return [
|
|
404
405
|
bold(key),
|
|
405
|
-
|
|
406
|
+
dim(formattedType),
|
|
406
407
|
description
|
|
407
408
|
].filter(isTruthy);
|
|
408
409
|
}))
|
|
@@ -481,14 +482,15 @@ var HelpRenderer = class {
|
|
|
481
482
|
}
|
|
482
483
|
renderFlagItem(name, flag) {
|
|
483
484
|
flag = normalizeFlagValue(flag);
|
|
484
|
-
|
|
485
|
-
|
|
485
|
+
let flagName = formatFlagName(name);
|
|
486
|
+
if (flag.short) flagName += `, ${formatFlagName(flag.short)}`;
|
|
486
487
|
const type = this._formatters.formatTypeValue(flag.type);
|
|
488
|
+
const default_ = flag.default !== void 0 && dim(`[default: ${bold(this._formatters.formatFlagDefault(flag.default))}]`);
|
|
487
489
|
return [
|
|
488
|
-
bold(
|
|
490
|
+
bold(flagName),
|
|
489
491
|
dim(type),
|
|
490
492
|
flag.description,
|
|
491
|
-
|
|
493
|
+
default_
|
|
492
494
|
].filter(isTruthy);
|
|
493
495
|
}
|
|
494
496
|
renderGroupedFlags(flags, groupMap, itemType) {
|
|
@@ -642,9 +644,8 @@ const helpPlugin = ({ command = true, flag = true, showHelpWhenNoCommandSpecifie
|
|
|
642
644
|
//#endregion
|
|
643
645
|
//#region ../plugin-version/src/index.ts
|
|
644
646
|
const versionPlugin = ({ command = true, flag = true } = {}) => definePlugin({ setup: (cli) => {
|
|
645
|
-
const formattedVersion = formatVersion(cli._version);
|
|
646
647
|
if (command) cli.command("version", "Prints current version", {}).on("version", () => {
|
|
647
|
-
console.log(
|
|
648
|
+
console.log(formatVersion(cli._version));
|
|
648
649
|
});
|
|
649
650
|
if (flag) cli.globalFlag("version", "Prints current version", {
|
|
650
651
|
short: "V",
|
|
@@ -653,7 +654,7 @@ const versionPlugin = ({ command = true, flag = true } = {}) => definePlugin({ s
|
|
|
653
654
|
}).interceptor({
|
|
654
655
|
enforce: "pre",
|
|
655
656
|
handler: async (ctx, next) => {
|
|
656
|
-
if (ctx.flags.version) console.log(
|
|
657
|
+
if (ctx.flags.version) console.log(formatVersion(cli._version));
|
|
657
658
|
else await next();
|
|
658
659
|
}
|
|
659
660
|
});
|
|
@@ -1485,7 +1486,7 @@ const notFoundPlugin = () => definePlugin({ setup: (cli) => cli.interceptor({
|
|
|
1485
1486
|
const strictFlagsPlugin = () => definePlugin({ setup: (cli) => {
|
|
1486
1487
|
cli.interceptor(async (ctx, next) => {
|
|
1487
1488
|
const keys = Object.keys(ctx.rawParsed.unknown);
|
|
1488
|
-
if (!ctx.
|
|
1489
|
+
if (!ctx.command || keys.length === 0) await next();
|
|
1489
1490
|
else throw keys.length > 1 ? /* @__PURE__ */ new Error(`Unexpected flags: ${joinWithAnd(keys)}`) : /* @__PURE__ */ new Error(`Unexpected flag: ${keys[0]}`);
|
|
1490
1491
|
});
|
|
1491
1492
|
} });
|
|
@@ -1539,8 +1540,11 @@ function buildTabModel(globalFlags, commands) {
|
|
|
1539
1540
|
registerGlobalFlags(globalFlags, t);
|
|
1540
1541
|
for (const cmd of commands.values()) {
|
|
1541
1542
|
if (cmd.completions?.show === false) continue;
|
|
1542
|
-
|
|
1543
|
-
|
|
1543
|
+
let command = t;
|
|
1544
|
+
if (cmd.name !== "") {
|
|
1545
|
+
command = t.command(cmd.name, cmd.description ?? "");
|
|
1546
|
+
registerGlobalFlags(globalFlags, command);
|
|
1547
|
+
}
|
|
1544
1548
|
for (const [flagName, def] of Object.entries(cmd.flags ?? {})) {
|
|
1545
1549
|
const normalized = (0, src_exports.normalizeFlagValue)(def);
|
|
1546
1550
|
const desc = normalized.description ?? "";
|
|
@@ -1560,7 +1564,7 @@ const completionsPlugin = () => definePlugin({ setup: (cli) => {
|
|
|
1560
1564
|
} },
|
|
1561
1565
|
parameters: [{
|
|
1562
1566
|
key: "[shell]",
|
|
1563
|
-
description: "Shell type
|
|
1567
|
+
description: "Shell type",
|
|
1564
1568
|
type: supportedShellEnum
|
|
1565
1569
|
}]
|
|
1566
1570
|
}).on("completions", async (ctx) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/plugin-completions",
|
|
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 completions",
|
|
@@ -27,6 +27,9 @@
|
|
|
27
27
|
"exports": {
|
|
28
28
|
".": "./dist/index.js"
|
|
29
29
|
},
|
|
30
|
+
"bin": {
|
|
31
|
+
"my-cli": "./src/a.mjs"
|
|
32
|
+
},
|
|
30
33
|
"main": "./dist/index.js",
|
|
31
34
|
"module": "./dist/index.js",
|
|
32
35
|
"types": "dist/index.d.ts",
|
|
@@ -48,8 +51,8 @@
|
|
|
48
51
|
"@bomb.sh/tab": "^0.0.10"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
|
-
"@clerc/core": "1.0.0-beta.
|
|
52
|
-
"@clerc/utils": "1.0.0-beta.
|
|
54
|
+
"@clerc/core": "1.0.0-beta.27",
|
|
55
|
+
"@clerc/utils": "1.0.0-beta.27"
|
|
53
56
|
},
|
|
54
57
|
"peerDependencies": {
|
|
55
58
|
"@clerc/core": "*"
|