summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuncer Ayaz <tuncer.ayaz@gmail.com>2012-08-10 14:27:23 +0200
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2012-08-10 14:28:42 +0200
commit8f3873e0619cd6e8750e069e6da418d91a493fec (patch)
tree400c7b77cf89a69def74014c1923fdbeffc11149
parent75a6de27e70ddcc46d04061b5a3fac25d6854222 (diff)
rebar_utils: refactor get_experimental and get_deprecated funs
-rw-r--r--src/rebar_utils.erl38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 55263a7..34db1df 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -45,7 +45,7 @@
vcs_vsn/3,
deprecated/3, deprecated/4,
get_deprecated_global/4, get_deprecated_global/5,
- get_experimental_global/3,
+ get_experimental_global/3, get_experimental_local/3,
get_deprecated_list/4, get_deprecated_list/5,
get_deprecated_local/4, get_deprecated_local/5,
delayed_halt/1,
@@ -217,28 +217,14 @@ get_deprecated_global(Config, OldOpt, NewOpt, When) ->
get_deprecated_global(Config, OldOpt, NewOpt, undefined, When).
get_deprecated_global(Config, OldOpt, NewOpt, Default, When) ->
- case rebar_config:get_global(Config, NewOpt, Default) of
- Default ->
- case rebar_config:get_global(Config, OldOpt, Default) of
- Default ->
- Default;
- Old ->
- deprecated(OldOpt, NewOpt, When),
- Old
- end;
- New ->
- New
- end.
+ get_deprecated_3(fun rebar_config:get_global/3,
+ Config, OldOpt, NewOpt, Default, When).
get_experimental_global(Config, Opt, Default) ->
- Val = rebar_config:get_global(Config, Opt, Default),
- case Val of
- Default ->
- Default;
- Val ->
- ?CONSOLE("NOTICE: Using experimental option '~p'~n", [Opt]),
- Val
- end.
+ get_experimental_3(fun rebar_config:get_global/3, Config, Opt, Default).
+
+get_experimental_local(Config, Opt, Default) ->
+ get_experimental_3(fun rebar_config:get_local/3, Config, Opt, Default).
get_deprecated_list(Config, OldOpt, NewOpt, When) ->
get_deprecated_list(Config, OldOpt, NewOpt, undefined, When).
@@ -350,6 +336,16 @@ get_deprecated_3(Get, Config, OldOpt, NewOpt, Default, When) ->
New
end.
+get_experimental_3(Get, Config, Opt, Default) ->
+ Val = Get(Config, Opt, Default),
+ case Val of
+ Default ->
+ Default;
+ Val ->
+ ?CONSOLE("NOTICE: Using experimental option '~p'~n", [Opt]),
+ Val
+ end.
+
%% We do the shell variable substitution ourselves on Windows and hope that the
%% command doesn't use any other shell magic.
patch_on_windows(Cmd, Env) ->