From ae54d70e6ce64b97f2d60400b24d1219369617b5 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Sun, 21 Dec 2014 11:02:20 -0500 Subject: Add support for namespace-based metacommands And more general namespace support --- rebar.config | 4 ++-- 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 -- cgit v1.1