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 number Diff line number Diff 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
17 changes: 12 additions & 5 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
toDiffScopeOptions,
} from "./diff-scope-options.js";
import { runPrep } from "./prep.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 Down Expand Up @@ -45,10 +45,17 @@ addDiffScopeOptions(
program
.command("show")
.description("Load a chapters.json file and open it in a local browser")
.argument("<path>", "Path to a chapters.json file"),
).action(async (jsonPath: string, refs: string[], opts: DiffCommandOptions) => {
await show(jsonPath, toDiffScopeOptions(refs, opts));
});
.argument("<path>", "Path to a chapters.json file")
.option("--validate", "Validate chapters without starting the server or opening the browser"),
).action(
async (jsonPath: string, refs: string[], opts: DiffCommandOptions & { validate?: boolean }) => {
if (opts.validate) {
await validate(jsonPath, toDiffScopeOptions(refs, opts));
} else {
await show(jsonPath, toDiffScopeOptions(refs, opts));
}
},
);

program.addCommand(commentsCommand());

Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/show.ts
Original file line number Diff line number Diff 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