public void displaySuggestions()

in analyzer/src/main/java/com/android/tools/sizereduction/analyzer/cli/TerminalInterface.java [132:193]


  public void displaySuggestions() {
    ImmutableListMultimap<Category, Suggestion> categorizedSuggestions = categorizeSuggestions();

    if (categorizedSuggestions.size() == 0) {
      System.out.println("No size saving suggestions found.");
      return;
    }
    ImmutableList<Category> categoryDisplayOrder = getCategoryDisplayOrder(categorizedSuggestions);

    Long runningTotal = 0L;
    for (Category category : categoryDisplayOrder) {
      ImmutableList<Suggestion> suggestions = categorizedSuggestions.get(category);
      Long totalSavings = getBytesSavedForSuggestionList(suggestions);
      System.out.println(
          Ansi.ansi()
              .fg(Color.GREEN)
              .a(CATEGORY_TO_STRING.get(category))
              .fg(Color.RED)
              .a(humanReadableByteCount(totalSavings))
              .reset());
      if (showFixes) {
        applyFixesInteractively(suggestions, category);
      } else {
        if (displayDetails) {
          suggestions.forEach(TerminalInterface::prettyPrintSuggestion);
        }
        if (applyFixes) {
          System.out.println("applying all available fixes for category: " + category);
          suggestions.stream()
              .filter(suggestion -> suggestion.getAutoFix() != null)
              .map(Suggestion::getAutoFix)
              .forEach(AutoFix::apply);
        }
      }
      runningTotal += totalSavings;
    }

    // Print out total size savings suggested.
    System.out.println(
        Ansi.ansi()
            .fg(Color.GREEN)
            .a("Total size savings of ")
            .fg(Color.RED)
            .a(humanReadableByteCount(runningTotal))
            .reset()
            .a(" found.")
            .reset());
    // if we are only showing suggestions, let them know of other available options.
    if (!applyFixes && !showFixes) {
      if (!displayDetails) {
        System.out.println(
            "The -d flag will display a list of individual suggestions for each category.");
      }
      // if there are any suggestions with a fix, explicitly let developers know they can apply them
      // or be shown them.
      if (this.suggestions.stream().anyMatch(suggestion -> suggestion.getAutoFix() != null)) {
        System.out.println(
            "The --apply-all flag will automatically apply any available fixes while"
                + " the --show-fixes flag allows for fixes to be selectively applied.");
      }
    }
  }