Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,6 +76,7 @@ navigation.
| `--compare <ref>` | Compare ref to diff against `--base` |
| `--ref <mode>` | Diff scope: `work` (staged + unstaged + untracked), `staged`, or `unstaged` (default: auto-detect) |
| `--pr <number-or-url>` | Review a GitHub pull request by number or URL (requires `gh`) |
| `--validate` | Validate chapters without starting the server or opening the browser |
| `--instructions <text>` | One-off instructions for chapter generation (up to 1000 characters; `prep` command) |

Examples:
Expand Down
10 changes: 8 additions & 2 deletions packages/cli/src/index.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@ import { z } from "zod";
import { runPrep } from "./prep.js";
import { WORKING_TREE_REF } from "./schema.js";
import type { DiffScopeOptions } from "./scope.js";
import { show } from "./show.js";
import { show, validate } from "./show.js";

const require = createRequire(import.meta.url);
const { version } = require("../package.json") as { version: string };
Expand All@@ -28,6 +28,7 @@ interface DiffCommandOptions {
ref?: string;
pr?: string;
instructions?: string;
validate?: boolean;
}

/**
Expand DownExpand Up@@ -79,9 +80,14 @@ program
.option("--base <ref>", "Base ref to diff against (default: auto-detect main/master)")
.option("--compare <ref>", "Compare ref to diff against --base")
.option("--pr <ref>", "Review a GitHub pull request by number or URL")
.option("--validate", "Validate chapters without starting the server or opening the browser")
.addOption(refOption)
.action(async (jsonPath: string, refs: string[], opts: DiffCommandOptions) => {
await show(jsonPath, toDiffScopeOptions(refs, opts));
if (opts.validate) {
await validate(jsonPath, toDiffScopeOptions(refs, opts));
} else {
await show(jsonPath, toDiffScopeOptions(refs, opts));
}
});

program.parseAsync(process.argv).catch((err) => {
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/show.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -79,6 +79,10 @@ export async function show(jsonPath: string, options: DiffScopeOptions): Promise
closeDb();
}

export async function validate(jsonPath: string, options: DiffScopeOptions): Promise<void> {
await buildChaptersFile(jsonPath, options);
}

interface BuiltChaptersFile {
chaptersFile: ChaptersFile;
/** The reviewed PR's number when `--pr` was used, else null. */
Expand Down