MCPcopy Index your code
hub / github.com/bombshell-dev/clack / note

Function note

packages/prompts/src/note.ts:37–66  ·  view source on GitHub ↗
(message = '', title = '', opts?: NoteOptions)

Source from the content-addressed store, hash-verified

35};
36
37export const note = (message = '', title = '', opts?: NoteOptions) => {
38 const output: Writable = opts?.output ?? process.stdout;
39 const hasGuide = opts?.withGuide ?? settings.withGuide;
40 const format = opts?.format ?? defaultNoteFormatter;
41 const wrapMsg = wrapWithFormat(message, getColumns(output) - 6, format);
42 const lines = ['', ...wrapMsg.split('\n').map(format), ''];
43 const titleLen = stringWidth(title);
44 const len =
45 Math.max(
46 lines.reduce((sum, ln) => {
47 const width = stringWidth(ln);
48 return width > sum ? width : sum;
49 }, 0),
50 titleLen
51 ) + 2;
52 const msg = lines
53 .map(
54 (ln) =>
55 `${styleText('gray', S_BAR)} ${ln}${' '.repeat(len - stringWidth(ln))}${styleText('gray', S_BAR)}`
56 )
57 .join('\n');
58 const leadingBorder = hasGuide ? `${styleText('gray', S_BAR)}\n` : '';
59 const bottomLeft = hasGuide ? S_CONNECT_LEFT : S_CORNER_BOTTOM_LEFT;
60 output.write(
61 `${leadingBorder}${styleText('green', S_STEP_SUBMIT)} ${styleText('reset', title)} ${styleText(
62 'gray',
63 S_BAR_H.repeat(Math.max(len - titleLen - 1, 1)) + S_CORNER_TOP_RIGHT
64 )}\n${msg}\n${styleText('gray', bottomLeft + S_BAR_H.repeat(len + 2) + S_CORNER_BOTTOM_RIGHT)}\n`
65 );
66};

Callers 2

mainFunction · 0.90

Calls 2

getColumnsFunction · 0.90
wrapWithFormatFunction · 0.85

Tested by

no test coverage detected