| 159 | } |
| 160 | |
| 161 | function 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 | } |