| 422 | // -- Output formatting -------------------------------------------------------- |
| 423 | |
| 424 | function formatTextOutput(changedFiles, markers, categories, lastCommit, currentHead) { |
| 425 | const shortCommit = lastCommit ? lastCommit.slice(0, 7) : 'initial'; |
| 426 | const lines = []; |
| 427 | |
| 428 | lines.push(`[watch] Scanned ${changedFiles.length} files since ${shortCommit}`); |
| 429 | |
| 430 | if (markers.length > 0) { |
| 431 | lines.push(' Markers found:'); |
| 432 | for (const m of markers) { |
| 433 | const desc = m.description ? ` ${m.description}` : ''; |
| 434 | lines.push(` ${m.file}:${m.line} -- @citadel: ${m.action}${desc}`); |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | const nonEmpty = Object.entries(categories).filter(([, files]) => files.length > 0); |
| 439 | if (nonEmpty.length > 0) { |
| 440 | lines.push(' File changes by category:'); |
| 441 | for (const [cat, files] of nonEmpty) { |
| 442 | lines.push(` ${cat}: ${files.join(', ')}`); |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | // Actions summary |
| 447 | const actionLines = []; |
| 448 | if (markers.length > 0) { |
| 449 | actionLines.push(`${markers.length} marker action${markers.length === 1 ? '' : 's'} ready for dispatch`); |
| 450 | } |
| 451 | if (categories.Tests.length > 0) { |
| 452 | actionLines.push(`${categories.Tests.length} test file${categories.Tests.length === 1 ? '' : 's'} changed (suggest test run)`); |
| 453 | } |
| 454 | if (actionLines.length > 0) { |
| 455 | lines.push(' Actions:'); |
| 456 | for (const a of actionLines) { |
| 457 | lines.push(` ${a}`); |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | if (changedFiles.length === 0 && markers.length === 0) { |
| 462 | lines.push(' No changes detected.'); |
| 463 | } |
| 464 | |
| 465 | return lines.join('\n'); |
| 466 | } |
| 467 | |
| 468 | // -- Commands ----------------------------------------------------------------- |
| 469 | |