import Table from 'cli-table3' const getColWidths = (...flex: number[]) => { const terminalWidth = process.stdout.columns - (flex.length + 1) const totalFlex = flex.reduce((total, flex) => total + flex, 0) return flex.map((flex) => Math.floor((flex / totalFlex) * terminalWidth)) } type TableOptions = Table.TableConstructorOptions export const createTerminalTable = (heads: Record, options: TableOptions = {}) => { return new Table({ head: Object.keys(heads), colWidths: getColWidths(...Object.values(heads)), wordWrap: true, wrapOnWordBoundary: false, ...options, }) }