summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-10-10 18:25:15 -0500
committerTristan Sloughter <t@crashfast.com>2014-10-10 18:25:15 -0500
commit26a53f323b2238f5d0b4988db6bae5c5ba384eab (patch)
tree54eebf91f87e3155e54dd66459cf16fca70135e6 /src
parent90cfb2a794e16dbf583a3591f448ced4a32f579f (diff)
print usage and desc of task for 'help task'
Diffstat (limited to 'src')
-rw-r--r--src/rebar_prv_help.erl23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/rebar_prv_help.erl b/src/rebar_prv_help.erl
index 4b843ca..5b9b8ca 100644
--- a/src/rebar_prv_help.erl
+++ b/src/rebar_prv_help.erl
@@ -25,13 +25,30 @@ init(State) ->
{deps, ?DEPS},
{example, "rebar help <task>"},
{short_desc, "Display a list of tasks or help for a given task or subtask."},
- {desc, ""},
- {opts, []}])),
+ {desc, "Display a list of tasks or help for a given task or subtask."},
+ {opts, [
+ {help_task, undefined, undefined, string, "Task to print help for."}
+ ]}])),
{ok, State1}.
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
- help(State),
+ {Args, _} = rebar_state:command_parsed_args(State),
+ case proplists:get_value(help_task, Args, undefined) of
+ undefined ->
+ help(State);
+ Name ->
+ Providers = rebar_state:providers(State),
+ Provider = providers:get_provider(list_to_atom(Name), Providers),
+ Opts = providers:opts(Provider),
+ case providers:desc(Provider) of
+ Desc when length(Desc) > 0 ->
+ io:format(Desc++"~n~n");
+ _ ->
+ ok
+ end,
+ getopt:usage(Opts, "rebar "++Name, "", [])
+ end,
{ok, State}.
%%