static void printEntries(PrintWriter writer,
                             String intro,
                             OptionalInt screenWidth,
                             List<String> entries) {
        if (entries.isEmpty()) {
            return;
        }
        if (!intro.isEmpty()) {
            writer.println(intro);
        }
        ColumnSchema columnSchema = calculateColumnSchema(screenWidth, entries);
        int numColumns = columnSchema.numColumns();
        int numLines = (entries.size() + numColumns - 1) / numColumns;
        for (int line = 0; line < numLines; line++) {
            StringBuilder output = new StringBuilder();
            for (int column = 0; column < numColumns; column++) {
                int entryIndex = line + (column * columnSchema.entriesPerColumn());
                if (entryIndex < entries.size()) {
                    String entry = entries.get(entryIndex);
                    output.append(entry);
                    if (column < numColumns - 1) {
                        int width = columnSchema.columnWidth(column);
                        for (int i = 0; i < width - entry.length(); i++) {
                            output.append(" ");
                        }
                    }
                }
            }
            writer.println(output);
        }
    }
@Test
    public void testPrintEntries() throws Exception {
        try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
            try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(
                    stream, StandardCharsets.UTF_8))) {
                LsCommandHandler.printEntries(writer, "", OptionalInt.of(18),
                    Arrays.asList("alphabet", "beta", "gamma", "theta", "zeta"));
            }
            assertEquals(String.join(String.format("%n"), Arrays.asList(
                "alphabet  theta",
                "beta      zeta",
                "gamma")), stream.toString().trim());
        }
    }