MCPcopy Index your code
hub / github.com/devcontainers/cli / encloseStringInBox

Function encloseStringInBox

src/spec-node/featuresCLI/info.ts:161–171  ·  view source on GitHub ↗
(str: string, indent: number = 0)

Source from the content-addressed store, hash-verified

159}
160
161function encloseStringInBox(str: string, indent: number = 0) {
162 const lines = str.split('\n');
163 lines[0] = `\u001b[1m${lines[0]}\u001b[22m`; // Bold
164 const maxWidth = Math.max(...lines.map(l => l.length - (l.includes('\u001b[1m') ? 9 : 0)));
165 const box = [
166 '┌' + '─'.repeat(maxWidth) + '┐',
167 ...lines.map(l => '│' + l.padEnd(maxWidth + (lines.length > 1 && l.includes('\u001b[1m') ? 9 : 0)) + '│'),
168 '└' + '─'.repeat(maxWidth) + '┘',
169 ];
170 return box.map(t => `${' '.repeat(indent)}${t}`).join('\n');
171}

Callers 1

featuresInfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected