From 26a53f323b2238f5d0b4988db6bae5c5ba384eab Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 10 Oct 2014 18:25:15 -0500 Subject: print usage and desc of task for 'help task' --- src/rebar_prv_help.erl | 23 ++++++++++++++++++++--- 1 file 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 "}, {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}. %% -- cgit v1.1