diff --git a/src/main/java/com/cube/shell/CubeShell.java b/src/main/java/com/cube/shell/CubeShell.java index d3164ee..ef8863b 100644 --- a/src/main/java/com/cube/shell/CubeShell.java +++ b/src/main/java/com/cube/shell/CubeShell.java @@ -961,35 +961,37 @@ // Print table System.out.println(); - - // Top border - printTableBorder(columns, colWidths, "┌", "┬", "┐"); - - // Header - System.out.print("│"); - for (String col : columns) { - int width = colWidths.get(col); - System.out.print(" " + padRight(col, width - 1) + "│"); - } - System.out.println(); - - // Header separator - printTableBorder(columns, colWidths, "├", "┼", "┤"); - - // Data rows - for (Map row : rows) { + + if (!columns.isEmpty()) { + // Top border + printTableBorder(columns, colWidths, "┌", "┬", "┐"); + + // Header System.out.print("│"); for (String col : columns) { int width = colWidths.get(col); - String val = row.getOrDefault(col, ""); - System.out.print(" " + padRight(truncate(val, 28), width - 1) + "│"); + System.out.print(" " + padRight(col, width - 1) + "│"); } System.out.println(); + + // Header separator + printTableBorder(columns, colWidths, "├", "┼", "┤"); + + // Data rows + for (Map row : rows) { + System.out.print("│"); + for (String col : columns) { + int width = colWidths.get(col); + String val = row.getOrDefault(col, ""); + System.out.print(" " + padRight(truncate(val, 28), width - 1) + "│"); + } + System.out.println(); + } + + // Bottom border + printTableBorder(columns, colWidths, "└", "┴", "┘"); + System.out.println(); } - - // Bottom border - printTableBorder(columns, colWidths, "└", "┴", "┘"); - System.out.println(); } /** diff --git a/target/classes/com/cube/shell/CubeShell.class b/target/classes/com/cube/shell/CubeShell.class index c6fe8dc..89b0493 100644 --- a/target/classes/com/cube/shell/CubeShell.class +++ b/target/classes/com/cube/shell/CubeShell.class Binary files differ