MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / dumpTable

Method dumpTable

packages/cli/src/CLIHelper.ts:290–324  ·  view source on GitHub ↗
(options: { columns: string[]; rows: string[][]; empty: string })

Source from the content-addressed store, hash-verified

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

Callers 3

handlePendingCommandMethod · 0.80
handleListCommandMethod · 0.80
CLIHelper.test.tsFile · 0.80

Calls 3

dumpMethod · 0.80
joinMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected