politty 0.4.14 → 0.4.16
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/README.md +7 -1
- package/dist/{arg-registry-CkPDokIu.d.ts → arg-registry-Cd6xnjHa.d.ts} +118 -4
- package/dist/arg-registry-Cd6xnjHa.d.ts.map +1 -0
- package/dist/{arg-registry-r5wYN6qd.d.cts → arg-registry-MVWOAcvw.d.cts} +118 -4
- package/dist/arg-registry-MVWOAcvw.d.cts.map +1 -0
- package/dist/augment.d.cts +1 -1
- package/dist/augment.d.cts.map +1 -1
- package/dist/augment.d.ts +1 -1
- package/dist/augment.d.ts.map +1 -1
- package/dist/completion/index.cjs +2 -1
- package/dist/completion/index.d.cts +2 -2
- package/dist/completion/index.d.ts +2 -2
- package/dist/completion/index.js +2 -2
- package/dist/{completion-yHz8Pdr7.js → completion-B04iiki9.js} +580 -31
- package/dist/completion-B04iiki9.js.map +1 -0
- package/dist/{completion-CAekGYS4.cjs → completion-BlZxMSeU.cjs} +598 -43
- package/dist/completion-BlZxMSeU.cjs.map +1 -0
- package/dist/docs/index.cjs +121 -65
- package/dist/docs/index.cjs.map +1 -1
- package/dist/docs/index.d.cts +5 -1
- package/dist/docs/index.d.cts.map +1 -1
- package/dist/docs/index.d.ts +5 -1
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +124 -67
- package/dist/docs/index.js.map +1 -1
- package/dist/{index-DPswv0Vt.d.cts → index-CPebddth.d.cts} +58 -4
- package/dist/index-CPebddth.d.cts.map +1 -0
- package/dist/{index-BLySW_2k.d.ts → index-DR9HLxIP.d.ts} +58 -4
- package/dist/index-DR9HLxIP.d.ts.map +1 -0
- package/dist/index.cjs +12 -10
- package/dist/index.d.cts +39 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +39 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/{subcommand-router-C9ONv6Nq.cjs → log-collector-Cd2_mv87.cjs} +1 -59
- package/dist/log-collector-Cd2_mv87.cjs.map +1 -0
- package/dist/{subcommand-router--EUt6ftA.js → log-collector-Cu6MCtAx.js} +2 -43
- package/dist/log-collector-Cu6MCtAx.js.map +1 -0
- package/dist/prompt/clack/index.cjs +1 -1
- package/dist/prompt/clack/index.cjs.map +1 -1
- package/dist/prompt/clack/index.d.cts +1 -1
- package/dist/prompt/clack/index.d.cts.map +1 -1
- package/dist/prompt/clack/index.d.ts +1 -1
- package/dist/prompt/clack/index.d.ts.map +1 -1
- package/dist/prompt/clack/index.js.map +1 -1
- package/dist/prompt/index.d.cts +1 -1
- package/dist/prompt/index.d.cts.map +1 -1
- package/dist/prompt/index.d.ts +1 -1
- package/dist/prompt/index.d.ts.map +1 -1
- package/dist/prompt/inquirer/index.cjs +1 -1
- package/dist/prompt/inquirer/index.cjs.map +1 -1
- package/dist/prompt/inquirer/index.d.cts +1 -1
- package/dist/prompt/inquirer/index.d.cts.map +1 -1
- package/dist/prompt/inquirer/index.d.ts +1 -1
- package/dist/prompt/inquirer/index.d.ts.map +1 -1
- package/dist/prompt/inquirer/index.js.map +1 -1
- package/dist/prompt-BKHqGrFw.js.map +1 -1
- package/dist/prompt-aXfSf27y.cjs.map +1 -1
- package/dist/{runner-DSZw1AsW.js → runner-BHeCMEa5.js} +383 -57
- package/dist/runner-BHeCMEa5.js.map +1 -0
- package/dist/{runner-CY5fOsSh.cjs → runner-BcyR6Z8r.cjs} +434 -96
- package/dist/runner-BcyR6Z8r.cjs.map +1 -0
- package/dist/{lazy-AGV9Pkt5.cjs → subcommand-router-DQy0KZU-.cjs} +148 -4
- package/dist/subcommand-router-DQy0KZU-.cjs.map +1 -0
- package/dist/{lazy-DiMJSDMB.js → subcommand-router-XZBWe8HN.js} +118 -4
- package/dist/subcommand-router-XZBWe8HN.js.map +1 -0
- package/package.json +16 -16
- package/dist/arg-registry-CkPDokIu.d.ts.map +0 -1
- package/dist/arg-registry-r5wYN6qd.d.cts.map +0 -1
- package/dist/completion-CAekGYS4.cjs.map +0 -1
- package/dist/completion-yHz8Pdr7.js.map +0 -1
- package/dist/index-BLySW_2k.d.ts.map +0 -1
- package/dist/index-DPswv0Vt.d.cts.map +0 -1
- package/dist/lazy-AGV9Pkt5.cjs.map +0 -1
- package/dist/lazy-DiMJSDMB.js.map +0 -1
- package/dist/runner-CY5fOsSh.cjs.map +0 -1
- package/dist/runner-DSZw1AsW.js.map +0 -1
- package/dist/subcommand-router--EUt6ftA.js.map +0 -1
- package/dist/subcommand-router-C9ONv6Nq.cjs.map +0 -1
package/dist/docs/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const require_log_collector = require('../log-collector-Cd2_mv87.cjs');
|
|
3
|
+
const require_subcommand_router = require('../subcommand-router-DQy0KZU-.cjs');
|
|
4
4
|
let zod = require("zod");
|
|
5
|
-
let node_util = require("node:util");
|
|
6
5
|
let node_fs = require("node:fs");
|
|
7
|
-
node_fs =
|
|
6
|
+
node_fs = require_log_collector.__toESM(node_fs, 1);
|
|
8
7
|
let node_path = require("node:path");
|
|
9
|
-
node_path =
|
|
8
|
+
node_path = require_log_collector.__toESM(node_path, 1);
|
|
9
|
+
let node_util = require("node:util");
|
|
10
10
|
|
|
11
11
|
//#region src/docs/types.ts
|
|
12
12
|
/**
|
|
@@ -114,6 +114,13 @@ function escapeTableCell$2(str) {
|
|
|
114
114
|
return str.replace(/\|/g, "\\|").replace(/\n/g, " ");
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
|
+
* Marker appended to a custom negation row/line so readers can see which
|
|
118
|
+
* positive flag it negates (e.g. `--monochrome` → `(↔ \`--color\`)`).
|
|
119
|
+
*/
|
|
120
|
+
function negationRelationMarker(opt) {
|
|
121
|
+
return `(↔ \`--${opt.cliName}\`)`;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
117
124
|
* Format default value for display
|
|
118
125
|
*/
|
|
119
126
|
function formatDefaultValue$1(value) {
|
|
@@ -174,25 +181,39 @@ function resolvePlaceholder(opt) {
|
|
|
174
181
|
}
|
|
175
182
|
/**
|
|
176
183
|
* Format option name for table display (e.g., `--dry-run` or `--port <PORT>`)
|
|
184
|
+
*
|
|
185
|
+
* Boolean fields with a custom inline `negation` (no separate description) are
|
|
186
|
+
* shown as `\`--cache\` / \`--disable-cache\``.
|
|
177
187
|
*/
|
|
178
188
|
function formatOptionName(opt) {
|
|
179
189
|
const placeholder = resolvePlaceholder(opt);
|
|
180
|
-
|
|
190
|
+
if (opt.type === "boolean") {
|
|
191
|
+
const positive = `\`--${opt.cliName}\``;
|
|
192
|
+
if (opt.negationDisplay && !opt.negationDescription) return `${positive} / \`--${opt.negationDisplay}\``;
|
|
193
|
+
return positive;
|
|
194
|
+
}
|
|
195
|
+
return `\`--${opt.cliName} <${placeholder}>\``;
|
|
181
196
|
}
|
|
182
197
|
/**
|
|
183
|
-
* Format option flags for list display (uses kebab-case cliName)
|
|
198
|
+
* Format option flags for list display (uses kebab-case cliName).
|
|
199
|
+
* Aliases are joined with `, `; the inline negation (when no separate
|
|
200
|
+
* `negationDescription` is set) is appended with ` / ` so it stays
|
|
201
|
+
* visually distinct from aliases, matching help and table output.
|
|
184
202
|
*/
|
|
185
203
|
function formatOptionFlags(opt) {
|
|
186
204
|
const placeholder = resolvePlaceholder(opt);
|
|
187
205
|
const longFlag = opt.type === "boolean" ? `--${opt.cliName}` : `--${opt.cliName} <${placeholder}>`;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
206
|
+
const parts = [];
|
|
207
|
+
if (opt.alias) {
|
|
208
|
+
for (const a of opt.alias) if (a.length === 1) parts.push(`\`-${a}\``);
|
|
209
|
+
}
|
|
210
|
+
parts.push(`\`${longFlag}\``);
|
|
211
|
+
if (opt.alias) {
|
|
212
|
+
for (const a of opt.alias) if (a.length > 1) parts.push(`\`--${a}\``);
|
|
213
|
+
}
|
|
214
|
+
const aliasJoined = parts.join(", ");
|
|
215
|
+
if (opt.type === "boolean" && opt.negationDisplay && !opt.negationDescription) return `${aliasJoined} / \`--${opt.negationDisplay}\``;
|
|
216
|
+
return aliasJoined;
|
|
196
217
|
}
|
|
197
218
|
/**
|
|
198
219
|
* Format aliases for a markdown table cell
|
|
@@ -244,6 +265,12 @@ function renderOptionsTable(info) {
|
|
|
244
265
|
const envNames = formatEnvNames(opt.env);
|
|
245
266
|
lines.push(`| ${optionName} | ${alias} | ${desc} | ${required} | ${defaultVal} | ${envNames} |`);
|
|
246
267
|
} else lines.push(`| ${optionName} | ${alias} | ${desc} | ${required} | ${defaultVal} |`);
|
|
268
|
+
if (opt.type === "boolean" && opt.negationDisplay && opt.negationDescription) {
|
|
269
|
+
const negName = `\`--${opt.negationDisplay}\``;
|
|
270
|
+
const negDesc = `${escapeTableCell$2(opt.negationDescription)} ${negationRelationMarker(opt)}`;
|
|
271
|
+
if (hasEnv) lines.push(`| ${negName} | - | ${negDesc} | ${required} | - | - |`);
|
|
272
|
+
else lines.push(`| ${negName} | - | ${negDesc} | ${required} | - |`);
|
|
273
|
+
}
|
|
247
274
|
}
|
|
248
275
|
return lines.join("\n");
|
|
249
276
|
}
|
|
@@ -268,6 +295,7 @@ function renderOptionsList(info) {
|
|
|
268
295
|
const defaultVal = opt.defaultValue !== void 0 ? ` (default: ${JSON.stringify(opt.defaultValue)})` : "";
|
|
269
296
|
const envInfo = formatEnvInfo(opt.env);
|
|
270
297
|
lines.push(`- ${flags}${desc}${required}${defaultVal}${envInfo}`);
|
|
298
|
+
if (opt.type === "boolean" && opt.negationDisplay && opt.negationDescription) lines.push(`- \`--${opt.negationDisplay}\` - ${opt.negationDescription} ${negationRelationMarker(opt)}`);
|
|
271
299
|
}
|
|
272
300
|
return lines.join("\n");
|
|
273
301
|
}
|
|
@@ -278,40 +306,19 @@ function generateAnchor$1(commandPath) {
|
|
|
278
306
|
return commandPath.join("-").toLowerCase();
|
|
279
307
|
}
|
|
280
308
|
/**
|
|
281
|
-
* Generate relative path from one file to another
|
|
309
|
+
* Generate relative path from one file to another.
|
|
310
|
+
* Always emits forward slashes so Markdown links remain portable across OSes.
|
|
282
311
|
*/
|
|
283
312
|
function getRelativePath(from, to) {
|
|
284
|
-
const
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
while (commonLength < fromParts.length && commonLength < toParts.length - 1 && fromParts[commonLength] === toParts[commonLength]) commonLength++;
|
|
288
|
-
const upCount = fromParts.length - commonLength;
|
|
289
|
-
return [...Array(upCount).fill(".."), ...toParts.slice(commonLength)].join("/") || (toParts[toParts.length - 1] ?? "");
|
|
313
|
+
const fromPosix = from.replace(/\\/g, "/");
|
|
314
|
+
const toPosix = to.replace(/\\/g, "/");
|
|
315
|
+
return node_path.default.posix.relative(node_path.default.posix.dirname(fromPosix), toPosix);
|
|
290
316
|
}
|
|
291
317
|
/**
|
|
292
318
|
* Render subcommands as table
|
|
293
319
|
*/
|
|
294
320
|
function renderSubcommandsTable(info, generateAnchors = true) {
|
|
295
|
-
|
|
296
|
-
const lines = [];
|
|
297
|
-
lines.push("| Command | Description |");
|
|
298
|
-
lines.push("|---------|-------------|");
|
|
299
|
-
const currentFile = info.filePath;
|
|
300
|
-
const fileMap = info.fileMap;
|
|
301
|
-
for (const sub of info.subCommands) {
|
|
302
|
-
const fullName = sub.fullPath.join(" ");
|
|
303
|
-
const desc = escapeTableCell$2(sub.description ?? "");
|
|
304
|
-
const subCommandPath = sub.fullPath.join(" ");
|
|
305
|
-
if (generateAnchors) {
|
|
306
|
-
const anchor = generateAnchor$1(sub.fullPath);
|
|
307
|
-
const subFile = fileMap?.[subCommandPath];
|
|
308
|
-
if (currentFile && subFile && currentFile !== subFile) {
|
|
309
|
-
const relativePath = getRelativePath(currentFile, subFile);
|
|
310
|
-
lines.push(`| [\`${fullName}\`](${relativePath}#${anchor}) | ${desc} |`);
|
|
311
|
-
} else lines.push(`| [\`${fullName}\`](#${anchor}) | ${desc} |`);
|
|
312
|
-
} else lines.push(`| \`${fullName}\` | ${desc} |`);
|
|
313
|
-
}
|
|
314
|
-
return lines.join("\n");
|
|
321
|
+
return renderSubcommandsTableFromArray(info.subCommands, info, generateAnchors);
|
|
315
322
|
}
|
|
316
323
|
/**
|
|
317
324
|
* Render options from array as table
|
|
@@ -337,6 +344,12 @@ function renderOptionsTableFromArray(options) {
|
|
|
337
344
|
const envNames = formatEnvNames(opt.env);
|
|
338
345
|
lines.push(`| ${optionName} | ${alias} | ${desc} | ${required} | ${defaultVal} | ${envNames} |`);
|
|
339
346
|
} else lines.push(`| ${optionName} | ${alias} | ${desc} | ${required} | ${defaultVal} |`);
|
|
347
|
+
if (opt.type === "boolean" && opt.negationDisplay && opt.negationDescription) {
|
|
348
|
+
const negName = `\`--${opt.negationDisplay}\``;
|
|
349
|
+
const negDesc = `${escapeTableCell$2(opt.negationDescription)} ${negationRelationMarker(opt)}`;
|
|
350
|
+
if (hasEnv) lines.push(`| ${negName} | - | ${negDesc} | ${required} | - | - |`);
|
|
351
|
+
else lines.push(`| ${negName} | - | ${negDesc} | ${required} | - |`);
|
|
352
|
+
}
|
|
340
353
|
}
|
|
341
354
|
return lines.join("\n");
|
|
342
355
|
}
|
|
@@ -418,6 +431,7 @@ function renderOptionsListFromArray(options) {
|
|
|
418
431
|
const defaultVal = opt.defaultValue !== void 0 ? ` (default: ${JSON.stringify(opt.defaultValue)})` : "";
|
|
419
432
|
const envInfo = formatEnvInfo(opt.env);
|
|
420
433
|
lines.push(`- ${flags}${desc}${required}${defaultVal}${envInfo}`);
|
|
434
|
+
if (opt.type === "boolean" && opt.negationDisplay && opt.negationDescription) lines.push(`- \`--${opt.negationDisplay}\` - ${opt.negationDescription} ${negationRelationMarker(opt)}`);
|
|
421
435
|
}
|
|
422
436
|
return lines.join("\n");
|
|
423
437
|
}
|
|
@@ -454,23 +468,31 @@ function renderArgumentsListFromArray(args) {
|
|
|
454
468
|
*/
|
|
455
469
|
function renderSubcommandsTableFromArray(subcommands, info, generateAnchors = true) {
|
|
456
470
|
if (subcommands.length === 0) return "";
|
|
471
|
+
const hasAliases = subcommands.some((s) => s.aliases && s.aliases.length > 0);
|
|
457
472
|
const lines = [];
|
|
458
|
-
|
|
459
|
-
|
|
473
|
+
if (hasAliases) {
|
|
474
|
+
lines.push("| Command | Aliases | Description |");
|
|
475
|
+
lines.push("|---------|---------|-------------|");
|
|
476
|
+
} else {
|
|
477
|
+
lines.push("| Command | Description |");
|
|
478
|
+
lines.push("|---------|-------------|");
|
|
479
|
+
}
|
|
460
480
|
const currentFile = info.filePath;
|
|
461
481
|
const fileMap = info.fileMap;
|
|
462
482
|
for (const sub of subcommands) {
|
|
463
483
|
const fullName = sub.fullPath.join(" ");
|
|
464
484
|
const desc = escapeTableCell$2(sub.description ?? "");
|
|
465
485
|
const subCommandPath = sub.fullPath.join(" ");
|
|
486
|
+
const aliasCell = hasAliases ? sub.aliases && sub.aliases.length > 0 ? sub.aliases.map((a) => `\`${escapeTableCell$2(a)}\``).join(", ") : "-" : "";
|
|
487
|
+
let cmdCell;
|
|
466
488
|
if (generateAnchors) {
|
|
467
489
|
const anchor = generateAnchor$1(sub.fullPath);
|
|
468
490
|
const subFile = fileMap?.[subCommandPath];
|
|
469
|
-
if (currentFile && subFile && currentFile !== subFile) {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
491
|
+
if (currentFile && subFile && currentFile !== subFile) cmdCell = `[\`${fullName}\`](${getRelativePath(currentFile, subFile)}#${anchor})`;
|
|
492
|
+
else cmdCell = `[\`${fullName}\`](#${anchor})`;
|
|
493
|
+
} else cmdCell = `\`${fullName}\``;
|
|
494
|
+
if (hasAliases) lines.push(`| ${cmdCell} | ${aliasCell} | ${desc} |`);
|
|
495
|
+
else lines.push(`| ${cmdCell} | ${desc} |`);
|
|
474
496
|
}
|
|
475
497
|
return lines.join("\n");
|
|
476
498
|
}
|
|
@@ -537,14 +559,19 @@ function createCommandRenderer(options = {}) {
|
|
|
537
559
|
const h = "#".repeat(effectiveLevel);
|
|
538
560
|
const title = info.commandPath || info.name;
|
|
539
561
|
sections.push(wrapWithMarker("heading", scope, `${h} ${title}`));
|
|
540
|
-
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
562
|
+
{
|
|
563
|
+
const parts = [];
|
|
564
|
+
if (info.description) parts.push(info.description);
|
|
565
|
+
if (info.aliases && info.aliases.length > 0) parts.push(`**Aliases:** ${info.aliases.map((a) => `\`${a}\``).join(", ")}`);
|
|
566
|
+
if (parts.length > 0) {
|
|
567
|
+
const context = {
|
|
568
|
+
content: parts.join("\n\n"),
|
|
569
|
+
heading: "",
|
|
570
|
+
info
|
|
571
|
+
};
|
|
572
|
+
const content = customRenderDescription ? customRenderDescription(context) : context.content;
|
|
573
|
+
if (content) sections.push(wrapWithMarker("description", scope, content));
|
|
574
|
+
}
|
|
548
575
|
}
|
|
549
576
|
{
|
|
550
577
|
const context = {
|
|
@@ -656,8 +683,11 @@ function createCommandRenderer(options = {}) {
|
|
|
656
683
|
* Default renderers presets
|
|
657
684
|
*/
|
|
658
685
|
const defaultRenderers = {
|
|
686
|
+
/** Standard command documentation */
|
|
659
687
|
command: (options) => createCommandRenderer(options),
|
|
688
|
+
/** Table style options (default) */
|
|
660
689
|
tableStyle: createCommandRenderer({ optionStyle: "table" }),
|
|
690
|
+
/** List style options */
|
|
661
691
|
listStyle: createCommandRenderer({ optionStyle: "list" })
|
|
662
692
|
};
|
|
663
693
|
|
|
@@ -762,7 +792,7 @@ function deleteFile(filePath, fileSystem = node_fs) {
|
|
|
762
792
|
* Build CommandInfo from a command
|
|
763
793
|
*/
|
|
764
794
|
async function buildCommandInfo(command, rootName, commandPath = []) {
|
|
765
|
-
const extracted =
|
|
795
|
+
const extracted = require_subcommand_router.getExtractedFields(command);
|
|
766
796
|
const positionalArgs = extracted?.fields.filter((f) => f.positional) ?? [];
|
|
767
797
|
const options = extracted?.fields.filter((f) => !f.positional) ?? [];
|
|
768
798
|
const subCommands = [];
|
|
@@ -772,12 +802,14 @@ async function buildCommandInfo(command, rootName, commandPath = []) {
|
|
|
772
802
|
subCommands.push({
|
|
773
803
|
name,
|
|
774
804
|
description: resolved.description,
|
|
805
|
+
aliases: resolved.aliases,
|
|
775
806
|
fullPath
|
|
776
807
|
});
|
|
777
808
|
}
|
|
778
809
|
return {
|
|
779
810
|
name: command.name ?? "",
|
|
780
811
|
description: command.description,
|
|
812
|
+
aliases: command.aliases,
|
|
781
813
|
fullCommandPath: commandPath.length > 0 ? `${rootName} ${commandPath.join(" ")}` : rootName,
|
|
782
814
|
commandPath: commandPath.join(" "),
|
|
783
815
|
depth: commandPath.length + 1,
|
|
@@ -837,11 +869,11 @@ async function executeExamples(examples, config, rootCommand, commandPath = [])
|
|
|
837
869
|
async function executeSingleExample(example, rootCommand, commandPath) {
|
|
838
870
|
const exampleArgs = parseExampleCmd(example.cmd);
|
|
839
871
|
const argv = [...commandPath, ...exampleArgs];
|
|
840
|
-
const collector =
|
|
872
|
+
const collector = require_log_collector.createLogCollector({ passthrough: false });
|
|
841
873
|
collector.start();
|
|
842
874
|
let success = true;
|
|
843
875
|
try {
|
|
844
|
-
const { runCommand } = await Promise.resolve().then(() => require("../runner-
|
|
876
|
+
const { runCommand } = await Promise.resolve().then(() => require("../runner-BcyR6Z8r.cjs")).then((n) => n.runner_exports);
|
|
845
877
|
const result = await runCommand(rootCommand, argv);
|
|
846
878
|
success = result.success;
|
|
847
879
|
if (!result.success && result.error) console.error(result.error.message);
|
|
@@ -905,7 +937,7 @@ function parseExampleCmd(cmd) {
|
|
|
905
937
|
* ResolvedFieldMeta format used by politty's rendering functions.
|
|
906
938
|
*/
|
|
907
939
|
function extractArgsFields(args) {
|
|
908
|
-
return
|
|
940
|
+
return require_subcommand_router.extractFields(zod.z.object(args)).fields;
|
|
909
941
|
}
|
|
910
942
|
/**
|
|
911
943
|
* Render args definition as a markdown options table
|
|
@@ -989,7 +1021,11 @@ function renderFilteredTable(options, columns) {
|
|
|
989
1021
|
for (const col of columns) switch (col) {
|
|
990
1022
|
case "option": {
|
|
991
1023
|
const placeholder = opt.placeholder ?? opt.cliName.toUpperCase().replace(/-/g, "_");
|
|
992
|
-
|
|
1024
|
+
let optionName;
|
|
1025
|
+
if (opt.type === "boolean") {
|
|
1026
|
+
optionName = `\`--${opt.cliName}\``;
|
|
1027
|
+
if (opt.negationDisplay && !opt.negationDescription) optionName += ` / \`--${opt.negationDisplay}\``;
|
|
1028
|
+
} else optionName = `\`--${opt.cliName} <${placeholder}>\``;
|
|
993
1029
|
cells.push(optionName);
|
|
994
1030
|
break;
|
|
995
1031
|
}
|
|
@@ -1012,6 +1048,26 @@ function renderFilteredTable(options, columns) {
|
|
|
1012
1048
|
}
|
|
1013
1049
|
}
|
|
1014
1050
|
lines.push(`| ${cells.join(" | ")} |`);
|
|
1051
|
+
if (opt.type === "boolean" && opt.negationDisplay && opt.negationDescription) {
|
|
1052
|
+
const negCells = [];
|
|
1053
|
+
for (const col of columns) switch (col) {
|
|
1054
|
+
case "option":
|
|
1055
|
+
negCells.push(`\`--${opt.negationDisplay}\``);
|
|
1056
|
+
break;
|
|
1057
|
+
case "description":
|
|
1058
|
+
negCells.push(`${escapeTableCell$1(opt.negationDescription)} ${negationRelationMarker(opt)}`);
|
|
1059
|
+
break;
|
|
1060
|
+
case "required":
|
|
1061
|
+
negCells.push(opt.required ? "Yes" : "No");
|
|
1062
|
+
break;
|
|
1063
|
+
case "alias":
|
|
1064
|
+
case "default":
|
|
1065
|
+
case "env":
|
|
1066
|
+
negCells.push("-");
|
|
1067
|
+
break;
|
|
1068
|
+
}
|
|
1069
|
+
lines.push(`| ${negCells.join(" | ")} |`);
|
|
1070
|
+
}
|
|
1015
1071
|
}
|
|
1016
1072
|
return lines.join("\n");
|
|
1017
1073
|
}
|
|
@@ -1533,7 +1589,7 @@ function isGlobalOptionsConfigWithOptions(config) {
|
|
|
1533
1589
|
* Positional args are not rendered in args tables, so they must not be excluded.
|
|
1534
1590
|
*/
|
|
1535
1591
|
function collectRenderableGlobalOptionFields(argsShape) {
|
|
1536
|
-
return
|
|
1592
|
+
return require_subcommand_router.extractFields(zod.z.object(argsShape)).fields.filter((field) => !field.positional);
|
|
1537
1593
|
}
|
|
1538
1594
|
/**
|
|
1539
1595
|
* Compare option definitions for global-options compatibility.
|
|
@@ -1956,7 +2012,7 @@ async function generateDoc(config) {
|
|
|
1956
2012
|
let rootDoc = config.rootDoc;
|
|
1957
2013
|
if (!rootDoc && usingPathConfig && (globalArgs || config.rootInfo)) rootDoc = { path: resolvedRootDocPath };
|
|
1958
2014
|
if (globalArgs && rootDoc && !rootDoc.globalOptions) {
|
|
1959
|
-
const optionFields =
|
|
2015
|
+
const optionFields = require_subcommand_router.extractFields(globalArgs).fields.filter((f) => !f.positional);
|
|
1960
2016
|
if (optionFields.length > 0) {
|
|
1961
2017
|
const globalShape = Object.fromEntries(optionFields.map((f) => [f.name, f.schema]));
|
|
1962
2018
|
rootDoc = {
|
|
@@ -2179,7 +2235,7 @@ async function generateDoc(config) {
|
|
|
2179
2235
|
if (globalOptionsResult.wasUpdated) markerUpdated = true;
|
|
2180
2236
|
}
|
|
2181
2237
|
const derivedCategories = deriveIndexFromFiles(files, rootDocFilePath, allCommands, ignores);
|
|
2182
|
-
const indexScope = node_path.relative(process.cwd(), rootDocFilePath);
|
|
2238
|
+
const indexScope = node_path.relative(process.cwd(), rootDocFilePath).replace(/\\/g, "/");
|
|
2183
2239
|
const indexResult = await processIndexMarker(content, derivedCategories, command, indexScope, updateMode, formatter, rootDoc.index);
|
|
2184
2240
|
content = indexResult.content;
|
|
2185
2241
|
rootDocDiffs.push(...indexResult.diffs);
|