printContribution
uses tcmts.cli.style.bold, which uses node:util
import { STATUS, when } from "#codebase/tcmts/cli/contributions"; import type { ContributionView } from "#codebase/tcmts/cli/contributions"; import { printReport } from "#codebase/tcmts/cli/diff"; import { bold, dim, green, red, yellow } from "#codebase/tcmts/cli/style"; export function printContribution(v: ContributionView) { const c = v.contribution; console.log(`${bold(`#${c.id} ${c.title}`)} ${STATUS[c.status](c.status)}`); console.log( dim( ` ${c.source} → ${c.target} · opened by ${c.author} ${when(c.created)} · ${v.comments.length} comment(s)`, ), ); if (c.description) console.log(`\n${c.description.replace(/^/gm, " ")}`); const m = v.mergeable; if (m) { const says = { "up-to-date": dim(`${c.target} already has these changes`), "fast-forward": green(`✓ merges as a fast-forward`), clean: green( `✓ merges cleanly${m.kind === "clean" && m.asText ? `, ${m.asText.join(", ")} merged as text` : ""}`, ), conflicts: red( `✗ conflicts with ${c.target} in ${m.kind === "conflicts" ? m.names.join(", ") : ""}`, ), }[m.kind]; console.log(`\n ${says}`); } console.log(); printReport(v.report); if (v.comments.length) console.log(`\n${bold("Comments")}`); for (const k of v.comments) { console.log( ` ${bold(k.author)} ${dim(when(k.ts))}${k.about ? ` ${yellow(`on ${k.about}`)}` : ""}`, ); console.log(k.body.replace(/^/gm, " ")); } }
uses
- tcmts.cli.contributions.ContributionView
- tcmts.cli.contributions.STATUS
- tcmts.cli.contributions.when
- tcmts.cli.diff.printReport
- tcmts.cli.style.bold
- tcmts.cli.style.dim
- tcmts.cli.style.green
- tcmts.cli.style.red
- tcmts.cli.style.yellow