default.ex (804B)
1 defmodule Credo.CLI.Command.Categories.Output.Default do 2 @moduledoc false 3 4 alias Credo.CLI.Output 5 alias Credo.CLI.Output.UI 6 7 def print(_exec, categories) do 8 Enum.each(categories, &print_category/1) 9 end 10 11 defp print_category(%{color: color, title: title, description: text}) do 12 term_width = Output.term_columns() 13 14 UI.puts() 15 16 [ 17 :bright, 18 "#{color}_background" |> String.to_atom(), 19 color, 20 " ", 21 Output.foreground_color(color), 22 :normal, 23 " #{title}" |> String.pad_trailing(term_width - 1) 24 ] 25 |> UI.puts() 26 27 color 28 |> UI.edge() 29 |> UI.puts() 30 31 text 32 |> String.split("\n") 33 |> Enum.each(&print_line(&1, color)) 34 end 35 36 defp print_line(line, color) do 37 [UI.edge(color), " ", :reset, line] 38 |> UI.puts() 39 end 40 end