Skip to content

Commit

Permalink
Fix underlining of column names in print_table/1 (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
starbelly authored Dec 25, 2021
1 parent 0ab77ce commit aa4b869
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/rebar3_hex_results.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ underline_emphasis(Item) ->
io_lib:format("\e[1m\e[00m\e[4m~ts\e[24m", [Item]).

% Returns a str, expects first row to be a header
table(Rows) ->
[Header | Body] = align_rows(Rows),
Table = [pretty_header(Header), ""] ++ Body,
table([Headers | Body]) ->
Headers1 = [H ++ "|" || H <- Headers],
[Headers2 | Body1] = align_rows([Headers1 | Body]),
Table = [pretty_header(Headers2), ""] ++ Body1,
lists:foldl(fun(Row, Acc) ->
Acc ++ [io_lib:fwrite("~s~n", [lists:flatten(Row)])]
end,
Expand All @@ -38,7 +39,7 @@ table(Rows) ->

pretty_header(Header) ->
lists:map(fun(W) ->
[Value, Space] = rebar3_hex_io:str_split(W, " "),
[Value, Space] = rebar3_hex_io:str_split(W, "|"),
underline_emphasis(Value) ++ " " ++ Space end,
Header).

Expand Down

0 comments on commit aa4b869

Please sign in to comment.