void output()

in grails-cli/src/main/java/org/grails/forge/cli/command/ListFeatures.java [57:89]


    void output(ConsoleOutput consoleOutput) {
        FeatureContext featureContext = contextFactory.createFeatureContext(availableFeatures,
                Collections.emptyList(),
                applicationType,
                options,
                operatingSystem
                );
        GeneratorContext generatorContext = contextFactory.createGeneratorContext(null, featureContext, ConsoleOutput.NOOP);

        Set<Feature> defaultFeatures = generatorContext.getFeatures().getFeatures();
        List<Feature> allFeatures = availableFeatures.getFeatures().collect(Collectors.toList());

        int width = allFeatures.stream()
                .map(Feature::getName)
                .max(Comparator.comparingInt(String::length))
                .map(String::length).get() + 8;

        Map<String, List<Feature>> featuresByCategory = allFeatures.stream()
                .sorted(Comparator.comparing(Feature::getName))
                .collect(Collectors.groupingBy(Feature::getCategory));
        featuresByCategory = new TreeMap<>(featuresByCategory);

        consoleOutput.out("Available Features");
        consoleOutput.out("@|blue (+)|@ denotes the feature is included by default");
        consoleOutput.out("  " + String.format("%1$-" + width + "s", "Name") + "Description");
        consoleOutput.out("  " + new String(new char[width - 2]).replace("\0", "-") + "  ---------------");

        featuresByCategory.forEach((category, features) -> {
            consoleOutput.out("  @|bold,underline,magenta " + category + "|@");
            listFeatures(consoleOutput, defaultFeatures, features, width);
            consoleOutput.out("");
        });
    }