@politty/zod 0.1.0 → 0.1.1

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.
@@ -0,0 +1,3 @@
1
+ import { t as runPolittyCli } from "./cli-main-D4kkrRfX.js";
2
+
3
+ export { runPolittyCli };
@@ -1,6 +1,6 @@
1
1
  import { a as internalField, i as internalArgs } from "./schema-extractor-DMSozq40.js";
2
2
  import { n as defineCommand } from "./command-k-4yAz4J.js";
3
- import { n as runMain } from "./runner-UEbd9e-3.js";
3
+ import { n as runMain } from "./runner-DAGvxV2P.js";
4
4
  import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
5
  import { basename, dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
@@ -239,7 +239,7 @@ const generateWorkerCommand = defineCommand({
239
239
  description: "Generate and verify a bundled shell completion worker",
240
240
  args: generateWorkerArgsSchema,
241
241
  async run(args) {
242
- const { generateBundledCompletionWorker } = await import("./src-zNS0DTqZ.js");
242
+ const { generateBundledCompletionWorker } = await import("./src-CLogLsbS.js");
243
243
  await generateBundledCompletionWorker({
244
244
  bin: args.bin,
245
245
  programName: args.program,
@@ -1,7 +1,7 @@
1
1
  import "./register-DlGnMLIY.js";
2
2
 
3
3
  //#region src/cli-run.ts
4
- const { runPolittyCli } = await import("./cli-main-B5mwyz8q.js");
4
+ const { runPolittyCli } = await import("./cli-main-BQfutJEX.js");
5
5
  await runPolittyCli("@politty/zod");
6
6
 
7
7
  //#endregion
package/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ import { n as enableCompileCache } from "./compile-cache-BC65o7MH.js";
10
10
  * before any code runs, so they could never hit a cache enabled here.
11
11
  */
12
12
  enableCompileCache("politty");
13
- await import("./cli-run-BlcK64io.js");
13
+ await import("./cli-run-wxd6kPPf.js");
14
14
 
15
15
  //#endregion
16
16
  export { };
package/dist/docs.js CHANGED
@@ -67,10 +67,19 @@ function toOptionRows(options) {
67
67
  return options.map(toOptionRow);
68
68
  }
69
69
  /**
70
- * Escape markdown special characters in table cells.
70
+ * Convert hard line breaks in a description into `<br>` so they render as line
71
+ * breaks inside a single markdown table cell or list item, instead of breaking
72
+ * the surrounding table row / list structure.
73
+ */
74
+ function inlineMarkdownBreaks(str) {
75
+ return str.replace(/\r?\n/g, "<br>");
76
+ }
77
+ /**
78
+ * Escape markdown special characters in table cells. Embedded line breaks are
79
+ * converted to `<br>` so multi-line descriptions stay within a single cell.
71
80
  */
72
81
  function escapeTableCell$2(str) {
73
- return str.replace(/\|/g, "\\|").replace(/\n/g, " ");
82
+ return inlineMarkdownBreaks(str.replace(/\|/g, "\\|"));
74
83
  }
75
84
  function backtick(value) {
76
85
  return `\`${value}\``;
@@ -195,12 +204,12 @@ function emitMarkdownList(rows) {
195
204
  ...longAliases
196
205
  ].map(backtick).join(", ");
197
206
  if (row.inlineNegation) flags += ` / ${backtick(row.inlineNegation)}`;
198
- const desc = row.description ? ` - ${row.description}` : "";
207
+ const desc = row.description ? ` - ${inlineMarkdownBreaks(row.description)}` : "";
199
208
  const required = row.required ? " (required)" : "";
200
209
  const defaultVal = row.hasDefault ? ` (default: ${JSON.stringify(row.defaultValue)})` : "";
201
210
  const envInfo = formatEnvInfo(row.env);
202
211
  lines.push(`- ${flags}${desc}${required}${defaultVal}${envInfo}`);
203
- if (row.negationRow) lines.push(`- ${backtick(row.negationRow.flag)} - ${row.negationRow.description} ${row.negationRow.relationMarker}`);
212
+ if (row.negationRow) lines.push(`- ${backtick(row.negationRow.flag)} - ${inlineMarkdownBreaks(row.negationRow.description)} ${row.negationRow.relationMarker}`);
204
213
  }
205
214
  return lines.join("\n");
206
215
  }
@@ -306,10 +315,11 @@ function indexEndMarker(scope) {
306
315
  //#endregion
307
316
  //#region ../core/src/docs/default-renderers.ts
308
317
  /**
309
- * Escape markdown special characters in table cells
318
+ * Escape markdown special characters in table cells. Embedded line breaks are
319
+ * converted to `<br>` so multi-line descriptions stay within a single cell.
310
320
  */
311
321
  function escapeTableCell$1(str) {
312
- return str.replace(/\|/g, "\\|").replace(/\n/g, " ");
322
+ return inlineMarkdownBreaks(str.replace(/\|/g, "\\|"));
313
323
  }
314
324
  /**
315
325
  * Render usage line
@@ -346,7 +356,7 @@ function renderArgumentsList(info) {
346
356
  const lines = [];
347
357
  for (const arg of info.positionalArgs) {
348
358
  const required = arg.required ? "(required)" : "(optional)";
349
- const desc = arg.description ? ` - ${arg.description}` : "";
359
+ const desc = arg.description ? ` - ${inlineMarkdownBreaks(arg.description)}` : "";
350
360
  lines.push(`- \`${arg.name}\`${desc} ${required}`);
351
361
  }
352
362
  return lines.join("\n");
@@ -503,7 +513,7 @@ function renderArgumentsListFromArray(args) {
503
513
  const lines = [];
504
514
  for (const arg of args) {
505
515
  const required = arg.required ? "(required)" : "(optional)";
506
- const desc = arg.description ? ` - ${arg.description}` : "";
516
+ const desc = arg.description ? ` - ${inlineMarkdownBreaks(arg.description)}` : "";
507
517
  lines.push(`- \`${arg.name}\`${desc} ${required}`);
508
518
  }
509
519
  return lines.join("\n");
@@ -921,7 +931,7 @@ async function executeSingleExample(example, rootCommand, commandPath) {
921
931
  collector.start();
922
932
  let success = true;
923
933
  try {
924
- const { runCommand } = await import("./runner-DR5Lw7LX.js");
934
+ const { runCommand } = await import("./runner-MMjpKeEa.js");
925
935
  const result = await runCommand(rootCommand, argv);
926
936
  success = result.success;
927
937
  if (!result.success && result.error) console.error(result.error.message);
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { i as toKebabCase, r as toCamelCase } from "./field-meta-DMy5BcRr.js";
2
2
  import { t as arg$1 } from "./register-DlGnMLIY.js";
3
3
  import { r as getUnknownKeysMode, t as extractFields } from "./schema-extractor-DMSozq40.js";
4
- import { n as createCompileCacheShimGenerator, t as runPolittyCli } from "./cli-main-Cdz55PLM.js";
4
+ import { n as createCompileCacheShimGenerator, t as runPolittyCli } from "./cli-main-D4kkrRfX.js";
5
5
  import { n as defineCommand$1, t as createDefineCommand$1 } from "./command-k-4yAz4J.js";
6
- import { C as ReservedFieldNameError, E as renderMarkdown, S as ReservedAliasError, T as renderInline, _ as DuplicateAliasError, a as parseArgv, b as FieldTypeConflictError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as CaseVariantCollisionError, h as validateReservedFieldNames, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, r as createDualCaseProxy, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateFieldError, w as generateHelp, x as PositionalConfigError, y as DuplicateNegationError } from "./runner-UEbd9e-3.js";
6
+ import { C as ReservedFieldNameError, E as renderMarkdown, S as ReservedAliasError, T as renderInline, _ as DuplicateAliasError, a as parseArgv, b as FieldTypeConflictError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as CaseVariantCollisionError, h as validateReservedFieldNames, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, r as createDualCaseProxy, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateFieldError, w as generateHelp, x as PositionalConfigError, y as DuplicateNegationError } from "./runner-DAGvxV2P.js";
7
7
  import { o as isLazyCommand, s as lazy } from "./subcommand-router-Cskpofdk.js";
8
8
  import { a as symbols, i as styles, n as logger, r as setColorEnabled, t as isColorEnabled } from "./logger-i_bb-Jhc.js";
9
9
  import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-DW5qVc3l.js";
10
- import "./src-DO4W2NcZ.js";
10
+ import "./src-bYH2XCQ4.js";
11
11
 
12
12
  //#region src/index.ts
13
13
  /**
@@ -737,16 +737,31 @@ function padEndVisual(str, width) {
737
737
  return str + " ".repeat(padding);
738
738
  }
739
739
  /**
740
+ * Re-indent the continuation lines of a multi-line description so they align
741
+ * under the description column. A `\n` in a description is treated as a hard
742
+ * line break; every line after the first is padded to `column` spaces.
743
+ */
744
+ function indentDescription(description, column) {
745
+ if (!description.includes("\n")) return description;
746
+ const pad = " ".repeat(column);
747
+ return description.split("\n").join(`\n${pad}`);
748
+ }
749
+ /**
740
750
  * Format a single option line
741
751
  * If flags exceed the column width, description is moved to the next line
752
+ *
753
+ * Descriptions may contain `\n` line breaks; continuation lines are indented to
754
+ * stay aligned under the description column.
742
755
  */
743
756
  function formatOption(flags, description, indent = 0, extraDescPadding = 0) {
744
757
  const flagWidth = 32;
745
758
  const indentStr = " ".repeat(indent);
746
759
  const visualFlagLength = stripAnsi(flags).length;
747
760
  const effectiveFlagWidth = flagWidth - indent * 2 + extraDescPadding;
748
- if (visualFlagLength >= effectiveFlagWidth) return `${indentStr} ${flags}\n${" ".repeat(effectiveFlagWidth + 2 + indent * 2)}${description}`;
749
- return `${indentStr} ${padEndVisual(flags, effectiveFlagWidth)}${description}`;
761
+ const descColumn = effectiveFlagWidth + 2 + indent * 2;
762
+ const desc = indentDescription(description, descColumn);
763
+ if (visualFlagLength >= effectiveFlagWidth) return `${indentStr} ${flags}\n${" ".repeat(descColumn)}${desc}`;
764
+ return `${indentStr} ${padEndVisual(flags, effectiveFlagWidth)}${desc}`;
750
765
  }
751
766
  /**
752
767
  * Format a single option field as a help line
@@ -881,7 +896,7 @@ function renderExamplesForHelp(examples, context) {
881
896
  const cmdPath = context?.commandPath?.join(" ") ?? "";
882
897
  const fullPrefix = cmdPath ? `${cmdPrefix}${cmdPath} ` : cmdPrefix;
883
898
  for (const example of examples) {
884
- lines.push(` ${styles.dim(example.desc)}`);
899
+ lines.push(` ${styles.dim(example.desc).split("\n").join("\n ")}`);
885
900
  lines.push(` ${styles.dim("$")} ${fullPrefix}${example.cmd}`);
886
901
  if (example.output) for (const line of example.output.split("\n")) lines.push(` ${line}`);
887
902
  lines.push("");
@@ -0,0 +1,3 @@
1
+ import { n as runMain, t as runCommand } from "./runner-DAGvxV2P.js";
2
+
3
+ export { runCommand };
@@ -1,12 +1,12 @@
1
1
  import { i as toKebabCase, r as toCamelCase } from "./field-meta-DMy5BcRr.js";
2
2
  import { t as arg } from "./register-DlGnMLIY.js";
3
3
  import { r as getUnknownKeysMode, t as extractFields } from "./schema-extractor-DMSozq40.js";
4
- import { n as createCompileCacheShimGenerator, t as runPolittyCli } from "./cli-main-Cdz55PLM.js";
4
+ import { n as createCompileCacheShimGenerator, t as runPolittyCli } from "./cli-main-D4kkrRfX.js";
5
5
  import { n as defineCommand, t as createDefineCommand } from "./command-k-4yAz4J.js";
6
- import { C as ReservedFieldNameError, E as renderMarkdown, S as ReservedAliasError, T as renderInline, _ as DuplicateAliasError, a as parseArgv, b as FieldTypeConflictError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as CaseVariantCollisionError, h as validateReservedFieldNames, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, r as createDualCaseProxy, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateFieldError, w as generateHelp, x as PositionalConfigError, y as DuplicateNegationError } from "./runner-UEbd9e-3.js";
6
+ import { C as ReservedFieldNameError, E as renderMarkdown, S as ReservedAliasError, T as renderInline, _ as DuplicateAliasError, a as parseArgv, b as FieldTypeConflictError, c as validateCommand, d as validateDuplicateFields, f as validateDuplicateNegations, g as CaseVariantCollisionError, h as validateReservedFieldNames, i as formatValidationErrors, l as validateCrossSchemaCollisions, m as validateReservedAliases, n as runMain, o as formatCommandValidationErrors, p as validatePositionalConfig, r as createDualCaseProxy, s as validateCaseVariantCollisions, t as runCommand, u as validateDuplicateAliases, v as DuplicateFieldError, w as generateHelp, x as PositionalConfigError, y as DuplicateNegationError } from "./runner-DAGvxV2P.js";
7
7
  import { o as isLazyCommand, s as lazy } from "./subcommand-router-Cskpofdk.js";
8
8
  import { a as symbols, i as styles, n as logger, r as setColorEnabled, t as isColorEnabled } from "./logger-i_bb-Jhc.js";
9
9
  import { a as generateCompletion, p as generateBundledCompletionWorker, s as withCompletionCommand } from "./completion-DW5qVc3l.js";
10
- import "./src-DO4W2NcZ.js";
10
+ import "./src-bYH2XCQ4.js";
11
11
 
12
12
  export { generateBundledCompletionWorker };
@@ -0,0 +1,6 @@
1
+ import "./cli-main-D4kkrRfX.js";
2
+ import "./runner-DAGvxV2P.js";
3
+ import "./logger-i_bb-Jhc.js";
4
+ import "./completion-DW5qVc3l.js";
5
+
6
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@politty/zod",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A lightweight CLI framework inspired by citty with zod v4 registry integration for type-safe metadata management",
5
5
  "keywords": [
6
6
  "argument-parser",
@@ -71,7 +71,7 @@
71
71
  }
72
72
  },
73
73
  "dependencies": {
74
- "yaml": "^2.8.3"
74
+ "yaml": "^2.9.0"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@types/node": "25.9.5",
@@ -1,3 +0,0 @@
1
- import { t as runPolittyCli } from "./cli-main-Cdz55PLM.js";
2
-
3
- export { runPolittyCli };
@@ -1,3 +0,0 @@
1
- import { n as runMain, t as runCommand } from "./runner-UEbd9e-3.js";
2
-
3
- export { runCommand };
@@ -1,6 +0,0 @@
1
- import "./cli-main-Cdz55PLM.js";
2
- import "./runner-UEbd9e-3.js";
3
- import "./logger-i_bb-Jhc.js";
4
- import "./completion-DW5qVc3l.js";
5
-
6
- export { };