diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-04-04 13:15:47 +0000 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-04-04 13:29:46 +0000 |
commit | 60f7474632000aa052ee4d5cea2eb7fbc094cc74 (patch) | |
tree | decea5eb0ec74ce37a2a62d012b36d139b483bad | |
parent | 043a2f5453d51542b25cf18a268e4c4c279d1acb (diff) |
Support namespaces in help search
-rw-r--r-- | rebar.config | 2 | ||||
-rw-r--r-- | src/rebar_prv_help.erl | 28 |
2 files changed, 17 insertions, 13 deletions
diff --git a/rebar.config b/rebar.config index 3997d8d..8d64b5d 100644 --- a/rebar.config +++ b/rebar.config @@ -24,7 +24,7 @@ {branch, "master"}}}, {providers, "", {git, "https://github.com/tsloughter/providers.git", - {tag, "v1.3.0"}}}, + {tag, "v1.3.1"}}}, {erlydtl, ".*", {git, "https://github.com/erlydtl/erlydtl.git", {tag, "0.10.0"}}}, diff --git a/src/rebar_prv_help.erl b/src/rebar_prv_help.erl index b450023..be5717f 100644 --- a/src/rebar_prv_help.erl +++ b/src/rebar_prv_help.erl @@ -34,20 +34,14 @@ init(State) -> -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do(State) -> - {Args, _} = rebar_state:command_parsed_args(State), - case proplists:get_value(help_task, Args, undefined) of - undefined -> + case rebar_state:command_args(State) of + [] -> help(State), {ok, State}; - Name -> - Providers = rebar_state:providers(State), - case providers:get_provider(list_to_atom(Name), Providers) of - not_found -> - {error, io_lib:format("Unknown task ~s", [Name])}; - Provider -> - providers:help(Provider), - {ok, State} - end + [Name] -> % default namespace + task_help(default, list_to_atom(Name), State); + [Namespace, Name] -> + task_help(list_to_atom(Namespace), list_to_atom(Name), State) end. -spec format_error(any()) -> iolist(). @@ -66,3 +60,13 @@ help(State) -> providers:help(rebar_state:providers(State)), ?CONSOLE("~nRun 'rebar3 help <TASK>' for details.~n~n", []). + +task_help(Namespace, Name, State) -> + Providers = rebar_state:providers(State), + case providers:get_provider(Name, Providers, Namespace) of + not_found -> + {error, io_lib:format("Unknown task ~p", [Name])}; + Provider -> + providers:help(Provider), + {ok, State} + end. |