diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2014-12-21 11:02:20 -0500 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2014-12-21 11:02:20 -0500 |
commit | ae54d70e6ce64b97f2d60400b24d1219369617b5 (patch) | |
tree | bc980a5d3f17727c492d5624f19d7e77c57c6954 | |
parent | c25fbab1c60836ccbc20225b5a10eea2fb285d48 (diff) |
Add support for namespace-based metacommands
And more general namespace support
-rw-r--r-- | rebar.config | 4 | ||||
-rw-r--r-- | src/rebar_core.erl | 15 |
2 files changed, 14 insertions, 5 deletions
diff --git a/rebar.config b/rebar.config index 296713a..fd3e53f 100644 --- a/rebar.config +++ b/rebar.config @@ -22,8 +22,8 @@ {git, "https://github.com/erlware/erlware_commons.git", {branch, "master"}}}, {providers, "", - {git, "https://github.com/tsloughter/providers.git", - {tag, "v1.0.0"}}}, + {git, "https://github.com/ferd/providers.git", + {branch, "namespaces"}}}, {erlydtl, ".*", {git, "https://github.com/erlydtl/erlydtl.git", {tag, "0.9.4"}}}, diff --git a/src/rebar_core.erl b/src/rebar_core.erl index eaa546a..96ba426 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -37,8 +37,17 @@ process_command(State, Command) -> Providers = rebar_state:providers(State), TargetProviders = providers:get_target_providers(Command, Providers), case providers:get_provider(Command, Providers) of - not_found -> - {error, io_lib:format("Command ~p not found", [Command])}; + not_found when is_atom(Command) -> + Namespace = Command, + process_command(State, {Namespace, do}); + not_found when is_tuple(Command) -> + case Command of + {default,Cmd} -> + {error, io_lib:format("Command ~p not found", [Cmd])}; + {Namespace,Cmd} -> + {error, io_lib:format("Command ~p not found in namespace ~p", + [Cmd, Namespace])} + end; CommandProvider -> case Command of Command when Command =:= do @@ -62,7 +71,7 @@ process_command(State, Command) -> -spec do([{atom(), atom()}], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do([], State) -> {ok, State}; -do([{ProviderName, _} | Rest], State) -> +do([ProviderName | Rest], State) -> Provider = providers:get_provider(ProviderName ,rebar_state:providers(State)), case providers:do(Provider, State) of |