Links in help output
Print a clickable command name where the terminal understands OSC 8, and a separate URL column only where it does not, deciding the layout with supportsLink().
A help screen with a documentation link per command wants two layouts: on a terminal that
understands hyperlinks, the command name itself is the link; everywhere else, the URL has to be
printed. supportsLink(runtime) decides the layout, and linkFor(runtime) writes the link.
import { linkFor, supportsLink } from 'paratext/link';
const commands = [
['build', 'https://example.dev/docs/build'],
['deploy', 'https://example.dev/docs/deploy'],
];
function help(runtime) {
const link = linkFor(runtime);
return supportsLink(runtime)
? commands.map(([name, url]) => ` ${link(name, url)}`).join('\n')
: commands.map(([name, url]) => ` ${name.padEnd(8)}${url}`).join('\n');
}
console.log(JSON.stringify(help({ env: { TERM_PROGRAM: 'ghostty' }, isTTY: { stdout: true } })));
console.log(help({ env: {}, isTTY: { stdout: false } }));" \u001b]8;;https://example.dev/docs/build\u0007build\u001b]8;;\u0007\n \u001b]8;;https://example.dev/docs/deploy\u0007deploy\u001b]8;;\u0007"
build https://example.dev/docs/build
deploy https://example.dev/docs/deployWithout supportsLink, the pipe would get build (https://…) from the projection, which is
correct but reads worse in a column. paratext/link loads neither the registry nor the schema,
so a CLI pays for one capability. flagstaff's boxes and tables render their linked cells
through the same capability.
Coming from term-img
A term-img alternative with a drop-in path for image bytes: import terminalImage from paratext/term-img, graded 12 / 18 by term-img's own test suite — all six misses pass a file path, which paratext declines to read — then zero dependencies and no node:fs.
A notification when a long task ends
Send an OSC 9 desktop notification on terminals that show one, and print the same message as a line everywhere else — with no native binaries.