header

tcmts.cli.main.header · #3utrx5rs · term · runs on the server

uses tcmts.cli.style.dim, which uses node:util

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { cutSignature } from "#codebase/tcmts/cli/main";
import { Placement } from "#codebase/tcmts/cli/placement";
import { bold, dim } from "#codebase/tcmts/cli/style";
import { shortHash } from "#codebase/tcmts/core/hash";

export function header(cb: Codebase, hash: string): string {
  const rec = cb.store.getDef(hash)!;
  const names = cb.store.pathsOf(hash);
  const line = `${dim("//")} ${bold(names.join(", ") || "(unnamed)")} ${dim(shortHash(hash))} ${dim(cutSignature(rec.kind === "type" ? rec.signature : ": " + cb.store.shownSignature(rec)))}`;
  if (rec.kind === "type") return line;
  const placement = new Placement(cb);
  return `${line}
${dim(`// ${placement.describe(hash)}`)}`;
}

uses

used by