summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-09-18 18:35:12 -0500
committerTristan Sloughter <t@crashfast.com>2014-09-18 18:35:12 -0500
commit73ee56eace71065ff7fa15f0106c2f559a6e632b (patch)
tree5d2864cdf48f65ff45edc276e2f209c5923dd1fb /src
parent8de7a609ffbfa9e7d1539de3ad420413326b85c0 (diff)
add do task
Diffstat (limited to 'src')
-rw-r--r--src/rebar.app.src1
-rw-r--r--src/rebar_core.erl8
-rw-r--r--src/rebar_plugins.erl12
-rw-r--r--src/rebar_prv_do.erl45
-rw-r--r--src/rebar_prv_update.erl14
5 files changed, 64 insertions, 16 deletions
diff --git a/src/rebar.app.src b/src/rebar.app.src
index 59f35ca..2e21351 100644
--- a/src/rebar.app.src
+++ b/src/rebar.app.src
@@ -23,6 +23,7 @@
%% any_dir processing modules
{providers, [rebar_prv_escripter,
rebar_prv_deps,
+ rebar_prv_do,
rebar_prv_lock,
rebar_prv_install_deps,
rebar_prv_packages,
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index 8732074..cb021e3 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -30,10 +30,6 @@
-include("rebar.hrl").
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
process_command(State, Command) ->
true = rebar_utils:expand_code_path(),
LibDirs = rebar_state:get(State, lib_dirs, ?DEFAULT_LIB_DIRS),
@@ -50,6 +46,10 @@ process_command(State, Command) ->
Conf1
end, State, TargetProviders).
+%% ===================================================================
+%% Internal functions
+%% ===================================================================
+
update_code_path([]) ->
no_change;
update_code_path(Paths) ->
diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl
new file mode 100644
index 0000000..0fdbc6d
--- /dev/null
+++ b/src/rebar_plugins.erl
@@ -0,0 +1,12 @@
+%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 et
+
+-module(rebar_plugins).
+
+-export([]).
+
+-include("rebar.hrl").
+
+%% ===================================================================
+%% Public API
+%% ===================================================================
diff --git a/src/rebar_prv_do.erl b/src/rebar_prv_do.erl
new file mode 100644
index 0000000..a2ac648
--- /dev/null
+++ b/src/rebar_prv_do.erl
@@ -0,0 +1,45 @@
+%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 et
+
+-module(rebar_prv_do).
+
+-behaviour(rebar_provider).
+
+-export([init/1,
+ do/1]).
+
+-include("rebar.hrl").
+
+-define(PROVIDER, do).
+-define(DEPS, []).
+
+%% ===================================================================
+%% Public API
+%% ===================================================================
+
+-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
+init(State) ->
+ State1 = rebar_state:add_provider(State, #provider{name = ?PROVIDER,
+ provider_impl = ?MODULE,
+ bare = false,
+ deps = ?DEPS,
+ example = "rebar3 do <task1>, <task2>, ...",
+ short_desc = "Higher order provider for running multiple tasks in a sequence.",
+ desc = "",
+ opts = []}),
+ {ok, State1}.
+
+-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | relx:error().
+do(State) ->
+ Tasks = args_to_tasks(rebar_state:command_args(State)),
+ State1 = lists:foldl(fun(TaskArgs, StateAcc) ->
+ [TaskStr | Args] = string:tokens(TaskArgs, " "),
+ Task = list_to_atom(TaskStr),
+ StateAcc1 = rebar_state:set(StateAcc, task, Task),
+ StateAcc2 = rebar_state:command_args(StateAcc1, Args),
+ rebar_core:process_command(StateAcc2, Task)
+ end, State, Tasks),
+ {ok, State1}.
+
+args_to_tasks(Args) ->
+ [string:strip(T) || T <- string:tokens(string:join(Args, " "), ",")].
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
index 9df8e60..e19041a 100644
--- a/src/rebar_prv_update.erl
+++ b/src/rebar_prv_update.erl
@@ -33,18 +33,8 @@ init(State) ->
do(State) ->
case rebar_state:command_args(State) of
[Name] ->
- ?INFO("Updating ~s~n", [Name]),
-
- DepsDir = rebar_prv_install_deps:get_deps_dir(State),
- Deps = rebar_state:get(State, deps, []),
- {_, _, Source} = lists:keyfind(list_to_atom(Name), 1, Deps),
- TargetDir = rebar_prv_install_deps:get_deps_dir(DepsDir, Name),
- rebar_fetch:update_source1(TargetDir, Source),
- State1 = rebar_state:set(State, locks, []),
- {ok, State2} = rebar_prv_install_deps:do(State1),
- {ok, State3} = rebar_prv_lock:do(State2),
- {ok, State4} = rebar_prv_compile:do(State3),
- {ok, State4};
+ ?ERROR("NOT IMPLEMENTED: Updating ~s~n", [Name]),
+ {ok, State};
[] ->
?INFO("Updating package index...~n", []),
Url = url(State),