dbcat 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/table.ts +19 -15
package/package.json
CHANGED
package/src/table.ts
CHANGED
|
@@ -135,6 +135,7 @@ export function printTable(
|
|
|
135
135
|
const dim = Bun.enableANSIColors ? DIM : "";
|
|
136
136
|
const reset = Bun.enableANSIColors ? RESET : "";
|
|
137
137
|
const bold = Bun.enableANSIColors ? BOLD : "";
|
|
138
|
+
let content = [] as string[];
|
|
138
139
|
|
|
139
140
|
if (rows.length === 0) {
|
|
140
141
|
if (title) {
|
|
@@ -147,24 +148,25 @@ export function printTable(
|
|
|
147
148
|
const titleWidth = Bun.stringWidth(titleDisplay);
|
|
148
149
|
const innerWidth = contentWidth + 2;
|
|
149
150
|
const remainingWidth = innerWidth - titleWidth - 1;
|
|
150
|
-
|
|
151
|
+
content.push(
|
|
151
152
|
`${dim}${BOX.topLeft}${BOX.horizontal}${reset}${bold}${titleDisplay}${reset}${dim}${BOX.horizontal.repeat(
|
|
152
153
|
Math.max(0, remainingWidth),
|
|
153
154
|
)}${BOX.topRight}${reset}`,
|
|
154
155
|
);
|
|
155
|
-
|
|
156
|
+
content.push(
|
|
156
157
|
`${dim}${BOX.vertical}${reset} ${padRight(
|
|
157
158
|
emptyText,
|
|
158
159
|
contentWidth,
|
|
159
160
|
)} ${dim}${BOX.vertical}${reset}`,
|
|
160
161
|
);
|
|
161
|
-
|
|
162
|
+
content.push(
|
|
162
163
|
`${dim}${BOX.bottomLeft}${BOX.horizontal.repeat(innerWidth)}${BOX.bottomRight
|
|
163
164
|
}${reset}`,
|
|
164
165
|
);
|
|
165
166
|
} else {
|
|
166
|
-
|
|
167
|
+
content.push("(empty)");
|
|
167
168
|
}
|
|
169
|
+
console.log(content.join("\n"));
|
|
168
170
|
return;
|
|
169
171
|
}
|
|
170
172
|
|
|
@@ -285,11 +287,11 @@ export function printTable(
|
|
|
285
287
|
|
|
286
288
|
const beforeTitle = fullTopBorder.slice(0, 2);
|
|
287
289
|
const afterTitle = fullTopBorder.slice(2 + titleDisplayWidth);
|
|
288
|
-
|
|
290
|
+
content.push(
|
|
289
291
|
`${dim}${beforeTitle}${reset}${bold}${titleDisplay}${reset}${dim}${afterTitle}${reset}`,
|
|
290
292
|
);
|
|
291
293
|
} else {
|
|
292
|
-
|
|
294
|
+
content.push(`${dim}${fullTopBorder}${reset}`);
|
|
293
295
|
}
|
|
294
296
|
|
|
295
297
|
const header = columns
|
|
@@ -300,14 +302,14 @@ export function printTable(
|
|
|
300
302
|
: padRight(truncated, visibleColWidths[i]!);
|
|
301
303
|
})
|
|
302
304
|
.join(` ${dim}${BOX.vertical}${reset} `);
|
|
303
|
-
|
|
305
|
+
content.push(
|
|
304
306
|
`${dim}${BOX.vertical}${reset} ${header} ${dim}${BOX.vertical}${reset}`,
|
|
305
307
|
);
|
|
306
308
|
|
|
307
309
|
const headerSep = visibleColWidths
|
|
308
310
|
.map((w) => BOX.horizontal.repeat(w))
|
|
309
311
|
.join(`${BOX.horizontal}${BOX.headerCross}${BOX.horizontal}`);
|
|
310
|
-
|
|
312
|
+
content.push(
|
|
311
313
|
`${dim}${BOX.headerLeft}${BOX.horizontal}${headerSep}${BOX.horizontal}${BOX.headerRight}${reset}`,
|
|
312
314
|
);
|
|
313
315
|
|
|
@@ -325,13 +327,13 @@ export function printTable(
|
|
|
325
327
|
: padRight(truncate(part, visibleColWidths[i]!), visibleColWidths[i]!);
|
|
326
328
|
});
|
|
327
329
|
const line = pieces.join(` ${reset}${dim}${BOX.vertical}${reset} `);
|
|
328
|
-
|
|
330
|
+
content.push(`${reset}${dim}${BOX.vertical}${reset} ${line} ${reset}${dim}${BOX.vertical}${reset}`);
|
|
329
331
|
}
|
|
330
332
|
if (rowIdx < visibleFormattedRows.length - 1 || (rowIdx === visibleFormattedRows.length - 1 && infoText)) {
|
|
331
333
|
const rowSep = visibleColWidths
|
|
332
334
|
.map((w) => BOX.horizontal.repeat(w))
|
|
333
335
|
.join(`${BOX.horizontal}${BOX.headerCross}${BOX.horizontal}`);
|
|
334
|
-
|
|
336
|
+
content.push(`${dim}${BOX.headerLeft}${BOX.horizontal}${rowSep}${BOX.horizontal}${BOX.headerRight}${reset}`);
|
|
335
337
|
}
|
|
336
338
|
}
|
|
337
339
|
} else {
|
|
@@ -344,7 +346,7 @@ export function printTable(
|
|
|
344
346
|
: padRight(truncated, visibleColWidths[i]!);
|
|
345
347
|
})
|
|
346
348
|
.join(` ${dim}${BOX.vertical}${reset} `);
|
|
347
|
-
|
|
349
|
+
content.push(
|
|
348
350
|
`${dim}${BOX.vertical}${reset} ${line} ${dim}${BOX.vertical}${reset}`,
|
|
349
351
|
);
|
|
350
352
|
}
|
|
@@ -353,9 +355,8 @@ export function printTable(
|
|
|
353
355
|
if (infoText) {
|
|
354
356
|
const truncatedInfo = truncate(infoText, innerWidth);
|
|
355
357
|
const infoLine = padRight(truncatedInfo, innerWidth);
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
console.log(
|
|
358
|
+
content.push(`${dim}${BOX.vertical} ${infoLine} ${BOX.vertical}${reset}`);
|
|
359
|
+
content.push(
|
|
359
360
|
`${dim}${BOX.bottomLeft}${BOX.horizontal.repeat(totalInnerWidth)}${BOX.bottomRight
|
|
360
361
|
}${reset}`,
|
|
361
362
|
);
|
|
@@ -363,8 +364,11 @@ export function printTable(
|
|
|
363
364
|
const bottomBorder = visibleColWidths
|
|
364
365
|
.map((w) => BOX.horizontal.repeat(w))
|
|
365
366
|
.join(`${BOX.horizontal}${BOX.bottomCross}${BOX.horizontal}`);
|
|
366
|
-
|
|
367
|
+
content.push(
|
|
367
368
|
`${dim}${BOX.bottomLeft}${BOX.horizontal}${bottomBorder}${BOX.horizontal}${BOX.bottomRight}${reset}`,
|
|
368
369
|
);
|
|
369
370
|
}
|
|
371
|
+
|
|
372
|
+
console.log(content.join("\n"));
|
|
373
|
+
return;
|
|
370
374
|
}
|