Skip to content

Commit

Permalink
Generalize column error output
Browse files Browse the repository at this point in the history
  • Loading branch information
eproxus committed Mar 1, 2022
1 parent b5ec11a commit 87f330d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/rebar3_grisp_package.erl
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,15 @@ parse_columns(toolchain, undefined) ->
parse_columns(Type, Arg) ->
case Arg of
[] ->
Cs = [[" ", atom_to_binary(C), $\n] || C <- columns(Type)],
abort("No columns specified. Must be at least one of:~n~n~s", [Cs]);
abort_columns(Type, "No columns specified");
_ ->
ok
end,
Columns = [list_to_atom(C) || C <- string:split(Arg, ",", all)],
lists:foreach(fun(C) ->
case lists:member(C, columns(Type)) of
true -> ok;
false -> abort("Unknown column: ~p", [C])
false -> abort_columns(Type, "Unknown column: ~p", [C])
end
end, Columns),
Columns.
Expand Down Expand Up @@ -182,3 +181,8 @@ format_header(String) ->

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

abort_columns(Type, Msg) -> abort_columns(Type, Msg, []).
abort_columns(Type, Msg, Args) ->
Cs = lists:join($\n, [[" ", atom_to_binary(C)] || C <- columns(Type)]),
abort(Msg ++ "~nValid columns:~n~s", Args ++ [Cs]).

0 comments on commit 87f330d

Please sign in to comment.