MCPcopy
hub / github.com/inkeep/open-knowledge / previewCommand

Function previewCommand

packages/cli/src/commands/preview.ts:5–32  ·  view source on GitHub ↗
(getConfig: () => Config)

Source from the content-addressed store, hash-verified

3import type { PreviewResult } from '../content/preview.ts';
4
5export function previewCommand(getConfig: () => Config): Command {
6 return new Command('preview')
7 .description('Show what content the watcher will track (read-only)')
8 .action(async () => {
9 const { previewContent, formatPreviewBlock } = await import('../content/preview.ts');
10 const config = getConfig();
11 const cwd = process.cwd();
12 const contentDir = resolveContentDir(config, cwd);
13
14 let result: PreviewResult;
15 try {
16 result = previewContent({
17 projectDir: cwd,
18 contentDir,
19 });
20 } catch (e) {
21 console.error(`Content preview failed: ${e instanceof Error ? e.message : String(e)}`);
22 process.exitCode = 1;
23 return;
24 }
25
26 process.stdout.write(`${formatPreviewBlock(result, cwd)}\n`);
27
28 if (result.totalCount === 0 && result.warnings.length > 0) {
29 process.exitCode = 1;
30 }
31 });
32}

Callers 1

cli.tsFile · 0.90

Calls 5

previewContentFunction · 0.85
formatPreviewBlockFunction · 0.85
errorMethod · 0.65
writeMethod · 0.65
resolveContentDirFunction · 0.50

Tested by

no test coverage detected