printRows
uses process
The report of what saving does, a line per definition. Brief (TCM_BRIEF=1, as the MCP server's tools run
commands), what's saved only because it's in a cycle with what changed is one line, and a type is shown only where
it says something: what's new, and an update whose type changed.
import { cutSignature, listed, STATUS_LABEL } from "#codebase/tcmts/cli/main"; import type { Row } from "#codebase/tcmts/cli/main"; import { bold, dim, yellow } from "#codebase/tcmts/cli/style"; import type { DefRecord } from "#codebase/tcmts/core/types"; export function printRows(rows: Row[], shown: (def: DefRecord) => string = (d) => d.signature) { // what's identical says nothing new: more than a few are one line const same = rows.filter((r) => r.status === "identical"); const quiet = same.length > 3; const brief = process.env.TCM_BRIEF === "1"; const mates = brief ? rows.filter((r) => r.mate && !r.dependent && r.status !== "identical") : []; for (const r of rows) { if (quiet && r.status === "identical") continue; if (mates.includes(r)) continue; // re-derived against what changed, as a dependent is (the file uses it, so it's saved with it) if (r.dependent && r.status !== "identical") { console.log(`${yellow(" ~ updated ")} ${bold(r.path)} ${dim("(dependent)")}`); continue; } // a report line per definition: a type too long for one is cut (`tcm view` has all of it) const typed = !brief || r.status === "new" || r.status === "alias" || !!r.retyped; const sig = typed ? ` ${dim(cutSignature(r.def.kind === "type" ? r.def.signature : `: ${shown(r.def)}`))}` : ""; const note = [brief && r.retyped ? "type changed" : "", r.note ?? ""] .filter(Boolean) .join("; "); console.log(`${STATUS_LABEL[r.status]} ${bold(r.path)}${sig}${note ? dim(` (${note})`) : ""}`); } if (mates.length) console.log( dim( ` ~ ${mates.length} more in a cycle with it, saved with it as ${mates.length > 1 ? "they are" : "it is"}: ${listed( mates.map((r) => r.path), 3, )}`, ), ); if (quiet) console.log( dim( ` = identical ${same.length}: ${listed( same.map((r) => r.path), 4, )}`, ), ); }
uses
- tcmts.cli.main.Row
- tcmts.cli.main.STATUS_LABEL
- tcmts.cli.main.cutSignature
- tcmts.cli.main.listed
- tcmts.cli.style.bold
- tcmts.cli.style.dim
- tcmts.cli.style.yellow
- tcmts.core.types.DefRecord