summaryrefslogtreecommitdiff
path: root/src/rebar_provider.erl
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-09-17 21:41:49 -0500
committerTristan Sloughter <t@crashfast.com>2014-09-17 21:42:15 -0500
commit2357bdf67f2dd95468f07dea7acfa218e7d0d039 (patch)
treeb50b8970c4aca4d12d2d8081acd8e4a06241fe06 /src/rebar_provider.erl
parent1e5f9e707964ef4e522abd6c41eeed82917d181d (diff)
reworking of help display and parse of commands
Diffstat (limited to 'src/rebar_provider.erl')
-rw-r--r--src/rebar_provider.erl18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/rebar_provider.erl b/src/rebar_provider.erl
index 30f7d80..3c80a80 100644
--- a/src/rebar_provider.erl
+++ b/src/rebar_provider.erl
@@ -6,6 +6,7 @@
impl/1,
get_provider/2,
get_target_providers/2,
+ help/1,
format/1]).
-export_type([t/0]).
@@ -73,13 +74,26 @@ do(Provider, State) ->
impl(Provider) ->
Provider#provider.name.
+help(State) ->
+ Providers = rebar_state:providers(State),
+ Help = lists:sort([{ec_cnv:to_list(P#provider.name), P#provider.short_desc} || P <- Providers,
+ P#provider.bare =/= true]),
+ Longest = lists:max([length(X) || {X, _} <- Help]),
+
+ lists:foreach(fun({Name, ShortDesc}) ->
+ Length = length(Name),
+ Spacing = lists:duplicate(Longest - Length + 8, " "),
+ io:format("~s~s~s~n", [Name, Spacing, ShortDesc])
+ end, Help).
+
+
%% @doc print the provider module name
%%
%% @param T - The provider
%% @return An iolist describing the provider
-spec format(t()) -> iolist().
-format(#provider{provider_impl=Mod}) ->
- erlang:atom_to_list(Mod).
+format(#provider{name=Name}) ->
+ atom_to_list(Name).
get_target_providers(Target, State) ->
Providers = rebar_state:providers(State),