MCPcopy
hub / github.com/colbymchenry/codegraph / createVerboseProgress

Function createVerboseProgress

src/bin/codegraph.ts:257–285  ·  view source on GitHub ↗

* Create a plain-text progress callback for --verbose mode. * No animations, no ANSI tricks — just timestamped lines to stdout.

()

Source from the content-addressed store, hash-verified

255 * No animations, no ANSI tricks — just timestamped lines to stdout.
256 */
257function createVerboseProgress(): (progress: { phase: string; current: number; total: number; currentFile?: string }) => void {
258 let lastPhase = '';
259 let lastPct = -1;
260 const startTime = Date.now();
261
262 return (progress) => {
263 const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
264
265 if (progress.phase !== lastPhase) {
266 lastPhase = progress.phase;
267 lastPct = -1;
268 console.log(`[${elapsed}s] Phase: ${progress.phase}`);
269 }
270
271 if (progress.total > 0) {
272 const pct = Math.floor((progress.current / progress.total) * 100);
273 // Log every 5% to keep output manageable
274 if (pct >= lastPct + 5 || progress.current === progress.total) {
275 lastPct = pct;
276 console.log(`[${elapsed}s] ${progress.current}/${progress.total} (${pct}%)${progress.currentFile ? ` ${getGlyphs().dash} ${progress.currentFile}` : ''}`);
277 }
278 } else if (progress.current > 0) {
279 // Scanning phase (no total yet) — log periodically
280 if (progress.current % 1000 === 0 || progress.current === 1) {
281 console.log(`[${elapsed}s] ${formatNumber(progress.current)} files found`);
282 }
283 }
284 };
285}
286
287/**
288 * Print success message

Callers 1

mainFunction · 0.85

Calls 2

getGlyphsFunction · 0.90
formatNumberFunction · 0.70

Tested by

no test coverage detected