static void printTargets(PrintWriter writer,
                             OptionalInt screenWidth,
                             List<String> targetFiles,
                             List<TargetDirectory> targetDirectories) {
        printEntries(writer, "", screenWidth, targetFiles);
        boolean needIntro = !targetFiles.isEmpty() || targetDirectories.size() > 1;
        boolean firstIntro = targetFiles.isEmpty();
        for (TargetDirectory targetDirectory : targetDirectories) {
            String intro = "";
            if (needIntro) {
                if (!firstIntro) {
                    intro = intro + String.format("%n");
                }
                intro = intro + targetDirectory.name + ":";
                firstIntro = false;
            }
            log.trace("LS : targetDirectory name = {}, children = {}",
                targetDirectory.name, targetDirectory.children);
            printEntries(writer, intro, screenWidth, targetDirectory.children);
        }
    }
@Test
    public void testPrintTargets() throws Exception {
        try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
            try (PrintWriter writer = new PrintWriter(new OutputStreamWriter(
                    stream, StandardCharsets.UTF_8))) {
                LsCommandHandler.printTargets(writer, OptionalInt.of(18),
                    Arrays.asList("foo", "foobarbaz", "quux"), Arrays.asList(
                        new TargetDirectory("/some/dir",
                            Collections.singletonList("supercalifragalistic")),
                        new TargetDirectory("/some/other/dir",
                            Arrays.asList("capability", "delegation", "elephant",
                                "fungible", "green"))));
            }
            assertEquals(String.join(String.format("%n"), Arrays.asList(
                "foo        quux",
                "foobarbaz  ",
                "",
                "/some/dir:",
                "supercalifragalistic",
                "",
                "/some/other/dir:",
                "capability",
                "delegation",
                "elephant",
                "fungible",
                "green")), stream.toString().trim());
        }
    }