summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_core.erl17
-rw-r--r--src/rebar_prv_compile.erl18
-rw-r--r--src/rebar_prv_do.erl4
-rw-r--r--src/rebar_state.erl4
4 files changed, 27 insertions, 16 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index 340f2ae..147f64f 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -39,12 +39,17 @@ process_command(State, Command) ->
CommandProvider = providers:get_provider(Command
,Providers),
Opts = providers:opts(CommandProvider)++rebar3:global_option_spec_list(),
- case getopt:parse(Opts, rebar_state:command_args(State)) of
- {ok, Args} ->
- State2 = rebar_state:command_parsed_args(State, Args),
- do(TargetProviders, State2);
- {error, {invalid_option, Option}} ->
- {error, io_lib:format("Invalid option ~s on task ~p", [Option, Command])}
+ case Command of
+ do ->
+ do(TargetProviders, State);
+ _ ->
+ case getopt:parse(Opts, rebar_state:command_args(State)) of
+ {ok, Args} ->
+ State2 = rebar_state:command_parsed_args(State, Args),
+ do(TargetProviders, State2);
+ {error, {invalid_option, Option}} ->
+ {error, io_lib:format("Invalid option ~s on task ~p", [Option, Command])}
+ end
end.
-spec do([atom()], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl
index 773e8a9..60314b3 100644
--- a/src/rebar_prv_compile.erl
+++ b/src/rebar_prv_compile.erl
@@ -19,10 +19,9 @@
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
init(State) ->
- Jobs = ?DEFAULT_JOBS,
JobsHelp = io_lib:format(
"Number of concurrent workers a command may use. Default: ~B",
- [Jobs]),
+ [?DEFAULT_JOBS]),
State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER},
{module, ?MODULE},
{bare, false},
@@ -37,16 +36,18 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
- ProjectApps = rebar_state:project_apps(State),
- Deps = rebar_state:get(State, deps_to_build, []),
+ {ok, State1} = handle_args(State),
+
+ ProjectApps = rebar_state:project_apps(State1),
+ Deps = rebar_state:get(State1, deps_to_build, []),
lists:foreach(fun(AppInfo) ->
C = rebar_config:consult(rebar_app_info:dir(AppInfo)),
- S = rebar_state:new(rebar_state:new(), C, rebar_app_info:dir(AppInfo)),
+ S = rebar_state:new(State1, C, rebar_app_info:dir(AppInfo)),
build(S, AppInfo)
end, Deps++ProjectApps),
- {ok, State}.
+ {ok, State1}.
build(State, AppInfo) ->
?INFO("Compiling ~s~n", [rebar_app_info:name(AppInfo)]),
@@ -57,3 +58,8 @@ build(State, AppInfo) ->
%% ===================================================================
%% Internal functions
%% ===================================================================
+
+handle_args(State) ->
+ {Args, _} = rebar_state:command_parsed_args(State),
+ Jobs = proplists:get_value(jobs, Args, ?DEFAULT_JOBS),
+ {ok, rebar_state:set(State, jobs, Jobs)}.
diff --git a/src/rebar_prv_do.erl b/src/rebar_prv_do.erl
index 4bffd04..c8f383d 100644
--- a/src/rebar_prv_do.erl
+++ b/src/rebar_prv_do.erl
@@ -32,13 +32,13 @@ init(State) ->
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
Tasks = args_to_tasks(rebar_state:command_args(State)),
- State1 = lists:foldl(fun(TaskArgs, StateAcc) ->
+ State1 = lists:foldl(fun(TaskArgs, {ok, 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),
+ end, {ok, State}, Tasks),
{ok, State1}.
args_to_tasks(Args) ->
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index 20ec4a0..2d9266a 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -54,7 +54,7 @@ new(ParentState=#state_t{}, Config) ->
-spec new(t(), list(), file:name()) -> t().
new(ParentState, Config, Dir) ->
- _Opts = ParentState#state_t.opts,
+ Opts = ParentState#state_t.opts,
LocalOpts = case rebar_config:consult_file(?LOCK_FILE) of
[D] ->
[{locks, D} | Config];
@@ -64,7 +64,7 @@ new(ParentState, Config, Dir) ->
ProviderModules = [],
create_logic_providers(ProviderModules, ParentState#state_t{dir=Dir
- ,opts=LocalOpts}).
+ ,opts=lists:umerge(LocalOpts, Opts)}).
get(State, Key) ->
proplists:get_value(Key, State#state_t.opts).