Skip to content

Commit

Permalink
Fix grid:format to comply to version 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ziopio committed Sep 13, 2024
1 parent 7f0d445 commit 7b16169
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/rebar3_grisp_package.erl
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ table(Items, Columns) ->
All = lists:usort(fun(A, B) ->
compare(values(A, Columns), values(B, Columns))
end, Items),
Table = grid:format(All, #{
header => #{format => fun format_header/1},
columns => Columns}
),
Table = grid:format(All, #{header => titlecase, columns => Columns}),
io:format(Table).

format_size(Size) ->
Expand All @@ -183,13 +180,14 @@ format_size(Size, [_|Units]) ->
format_datetime(DateTime) ->
iolist_to_binary(calendar:system_time_to_rfc3339(DateTime)).

format_header(String) ->
Words = string:split(String, <<"_">>, all),
Formatted = lists:join($ , [titlecase(W) || W <- Words]),
grid:cell(cf:format("~!^~s", [Formatted]), string:length(String)).

titlecase(<<"os">>) -> <<"OS">>;
titlecase(String) -> string:titlecase(String).
% format_header(String) ->
% Words = string:split(String, <<"_">>, all),
% Formatted = lists:join($ , [titlecase(W) || W <- Words]),
% grid:cell(cf:format("~!^~s", [Formatted]), string:length(String)).

% titlecase(<<"os">>) -> <<"OS">>;
% titlecase(String) -> string:titlecase(String).

abort_columns(Type, Msg) -> abort_columns(Type, Msg, []).
abort_columns(Type, Msg, Args) ->
Expand Down

0 comments on commit 7b16169

Please sign in to comment.