summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-11-08 11:27:42 -0600
committerTristan Sloughter <t@crashfast.com>2014-11-08 11:27:42 -0600
commitbcb36896543e02682c6fb36409412bcad31b7e94 (patch)
tree540654366e2d05dbefc52b76b1dd1222fbffdc8c
parentf1ca7950c3a532721ca19679d272ae6c2170c05f (diff)
main module cleanup
-rw-r--r--src/rebar3.erl84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl
index 0a85c41..297233a 100644
--- a/src/rebar3.erl
+++ b/src/rebar3.erl
@@ -30,7 +30,6 @@
run/2,
global_option_spec_list/0,
init_config/0,
- init_config1/1,
set_options/2,
parse_args/1,
version/0,
@@ -87,7 +86,8 @@ run(RawArgs) ->
case erlang:system_info(version) of
"6.1" ->
- ?WARN("Due to a filelib bug in Erlang 17.1 it is recommended you update to a newer release.", []);
+ ?WARN("Due to a filelib bug in Erlang 17.1 it is recommended"
+ "you update to a newer release.", []);
_ ->
ok
end,
@@ -95,6 +95,35 @@ run(RawArgs) ->
{BaseConfig1, _Args1} = set_options(BaseConfig, {[], []}),
run_aux(BaseConfig1, RawArgs).
+run_aux(State, RawArgs) ->
+ %% Make sure crypto is running
+ case crypto:start() of
+ ok -> ok;
+ {error,{already_started,crypto}} -> ok
+ end,
+ application:start(asn1),
+ application:start(public_key),
+ application:start(ssl),
+ inets:start(),
+
+ %% Process each command, resetting any state between each one
+ State2 = case rebar_state:get(State, base_dir, undefined) of
+ undefined ->
+ rebar_state:set(State, base_dir, filename:absname(rebar_state:dir(State)));
+ Dir ->
+ rebar_state:set(State, base_dir, filename:absname(Dir))
+ end,
+
+ {ok, Providers} = application:get_env(rebar, providers),
+
+ {ok, PluginProviders, State3} = rebar_plugins:install(State2),
+ rebar_core:update_code_path(State3),
+
+ State4 = rebar_state:create_logic_providers(Providers++PluginProviders, State3),
+ {Task, Args} = parse_args(RawArgs),
+
+ rebar_core:process_command(rebar_state:command_args(State4, Args), list_to_atom(Task)).
+
init_config() ->
%% Initialize logging system
Verbosity = log_level(),
@@ -126,50 +155,19 @@ init_config() ->
rebar_state:new(Config1)
end,
- %% Initialize vsn cache
- rebar_state:set(State, vsn_cache, dict:new()).
-
-init_config1(BaseConfig) ->
%% Determine the location of the rebar executable; important for pulling
%% resources out of the escript
- try
- ScriptName = filename:absname(escript:script_name()),
- rebar_state:set(BaseConfig, escript, ScriptName)
- catch
- _:_ ->
- BaseConfig
- end.
-
-run_aux(State, RawArgs) ->
- %% Make sure crypto is running
- case crypto:start() of
- ok -> ok;
- {error,{already_started,crypto}} -> ok
- end,
- application:start(asn1),
- application:start(public_key),
- application:start(ssl),
- inets:start(),
-
- State1 = init_config1(State),
-
- %% Process each command, resetting any state between each one
- State2 = case rebar_state:get(State1, base_dir, undefined) of
- undefined ->
- rebar_state:set(State1, base_dir, filename:absname(rebar_state:dir(State1)));
- Dir ->
- rebar_state:set(State1, base_dir, filename:absname(Dir))
+ State1 = try
+ ScriptName = filename:absname(escript:script_name()),
+ rebar_state:set(State, escript, ScriptName)
+ catch
+ _:_ ->
+ State
end,
- {ok, Providers} = application:get_env(rebar, providers),
-
- {ok, PluginProviders, State3} = rebar_plugins:install(State2),
- rebar_core:update_code_path(State3),
-
- State4 = rebar_state:create_logic_providers(Providers++PluginProviders, State3),
- {Task, Args} = parse_args(RawArgs),
-
- rebar_core:process_command(rebar_state:command_args(State4, Args), list_to_atom(Task)).
+ %% TODO: Do we need this still? I think it may still be used.
+ %% Initialize vsn cache
+ rebar_state:set(State1, vsn_cache, dict:new()).
%%
%% Parse command line arguments using getopt and also filtering out any
@@ -224,6 +222,8 @@ version() ->
[Vsn, erlang:system_info(otp_release), erlang:system_info(version)]).
+
+%% TODO: Actually make it 'global'
%%
%% set global flag based on getopt option boolean value
%%