diff --git a/src/cli/commandManifests.ts b/src/cli/commandManifests.ts index 74a6a69333..3ce6dfb7a9 100644 --- a/src/cli/commandManifests.ts +++ b/src/cli/commandManifests.ts @@ -24,6 +24,7 @@ import { z } from "zod"; import type { CliCommandEntry } from "./commandRegistry.js"; +import { optionFlagName } from "./optionFields.js"; /** The manifests' format version, which callers may already check. */ const MANIFEST_VERSION = "incur.v1"; @@ -124,7 +125,7 @@ const commandBody = (cli: string, { name, definition }: CliCommandEntry) => { const text = field.description ?? ""; const description = property?.deprecated === true ? `**Deprecated.** ${text}` : text; - return `| \`--${key}\` | \`${tableType(property)}\` | ${fallback === "" ? "" : `\`${fallback}\``} | ${description} |`; + return `| \`--${optionFlagName(key)}\` | \`${tableType(property)}\` | ${fallback === "" ? "" : `\`${fallback}\``} | ${description} |`; }, ); sections.push( diff --git a/tests/boundary/cli/commandManifests.test.ts b/tests/boundary/cli/commandManifests.test.ts new file mode 100644 index 0000000000..9e9248c9ab --- /dev/null +++ b/tests/boundary/cli/commandManifests.test.ts @@ -0,0 +1,32 @@ +import { expect, it } from "vitest"; +import { z } from "zod"; + +import type { CliCommandEntry } from "../../../src/cli/commandRegistry.js"; +import { formatLlmsFull } from "../../../src/cli/commandManifests.js"; +import { formatCommandHelp } from "../../../src/cli/help.js"; + +it("uses the same canonical option flags as command help", () => { + const command: CliCommandEntry = { + name: "sample", + definition: { + options: z.object({ + blockSize: z.number().optional().describe("Bytes per block"), + dryRun: z.boolean().default(false).describe("Dry run"), + }), + run: () => undefined, + }, + operations: [], + source: { kind: "host" }, + }; + const help = formatCommandHelp("rea sample", { + options: command.definition.options, + }); + const manifest = formatLlmsFull("rea", [command]); + + expect(help).toContain("--block-size "); + expect(help).toContain("--dry-run"); + expect(manifest).toContain("| `--block-size` |"); + expect(manifest).toContain("| `--dry-run` |"); + expect(manifest).not.toContain("--blockSize"); + expect(manifest).not.toContain("--dryRun"); +}); diff --git a/tests/fixtures/cli-parity/discovery-llms-full-over-llms.txt b/tests/fixtures/cli-parity/discovery-llms-full-over-llms.txt index f03dd0fa9a..8d592e36fe 100644 --- a/tests/fixtures/cli-parity/discovery-llms-full-over-llms.txt +++ b/tests/fixtures/cli-parity/discovery-llms-full-over-llms.txt @@ -15,7 +15,7 @@ Inspect file-wide and block byte entropy without executing the file | Flag | Type | Default | Description | |------|------|---------|-------------| -| `--blockSize` | `unknown` | `4096` | Power-of-two block size from 256 to 65536 bytes | +| `--block-size` | `unknown` | `4096` | Power-of-two block size from 256 to 65536 bytes | | `--offset` | `unknown` | `0` | Window start as a decimal file byte offset | | `--length` | `unknown` | | Window length in bytes; omit to extend through EOF | diff --git a/tests/fixtures/cli-parity/llms-full-command.txt b/tests/fixtures/cli-parity/llms-full-command.txt index 665c6ff7d9..2766bfa8ec 100644 --- a/tests/fixtures/cli-parity/llms-full-command.txt +++ b/tests/fixtures/cli-parity/llms-full-command.txt @@ -15,7 +15,7 @@ Inspect file-wide and block byte entropy without executing the file | Flag | Type | Default | Description | |------|------|---------|-------------| -| `--blockSize` | `unknown` | `4096` | Power-of-two block size from 256 to 65536 bytes | +| `--block-size` | `unknown` | `4096` | Power-of-two block size from 256 to 65536 bytes | | `--offset` | `unknown` | `0` | Window start as a decimal file byte offset | | `--length` | `unknown` | | Window length in bytes; omit to extend through EOF |