(options: { columns: string[]; rows: string[][]; empty: string })
| 288 | } |
| 289 | |
| 290 | static dumpTable(options: { columns: string[]; rows: string[][]; empty: string }): void { |
| 291 | if (options.rows.length === 0) { |
| 292 | return CLIHelper.dump(options.empty); |
| 293 | } |
| 294 | |
| 295 | const data = [options.columns, ...options.rows]; |
| 296 | const lengths = options.columns.map(() => 0); |
| 297 | data.forEach(row => { |
| 298 | row.forEach((cell, idx) => { |
| 299 | lengths[idx] = Math.max(lengths[idx], cell.length + 2); |
| 300 | }); |
| 301 | }); |
| 302 | |
| 303 | let ret = ''; |
| 304 | ret += colors.grey('┌' + lengths.map(length => '─'.repeat(length)).join('┬') + '┐\n'); |
| 305 | ret += |
| 306 | colors.grey('│') + |
| 307 | lengths |
| 308 | .map( |
| 309 | (length, idx) => |
| 310 | ' ' + colors.red(options.columns[idx]) + ' '.repeat(length - options.columns[idx].length - 1), |
| 311 | ) |
| 312 | .join(colors.grey('│')) + |
| 313 | colors.grey('│\n'); |
| 314 | ret += colors.grey('├' + lengths.map(length => '─'.repeat(length)).join('┼') + '┤\n'); |
| 315 | options.rows.forEach(row => { |
| 316 | ret += |
| 317 | colors.grey('│') + |
| 318 | lengths.map((length, idx) => ' ' + row[idx] + ' '.repeat(length - row[idx].length - 1)).join(colors.grey('│')) + |
| 319 | colors.grey('│\n'); |
| 320 | }); |
| 321 | ret += colors.grey('└' + lengths.map(length => '─'.repeat(length)).join('┴') + '┘'); |
| 322 | |
| 323 | CLIHelper.dump(ret); |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | * Tries to register TS support in the following order: oxc, swc, tsx, jiti, tsimp |
no test coverage detected