aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Sloughter <[email protected]>2014-05-22 10:09:49 -0500
committerTristan Sloughter <[email protected]>2014-05-22 10:09:49 -0500
commitf2864cb3ba69c056d532467262335f28d1aa9d19 (patch)
treeec12996b909f84482c5234a2c0593ea3af4802bf
parent6a50af3feb7186d86365aafeafadb3822973e343 (diff)
downloadrelx-f2864cb3ba69c056d532467262335f28d1aa9d19.tar.gz
relx-f2864cb3ba69c056d532467262335f28d1aa9d19.tar.bz2
relx-f2864cb3ba69c056d532467262335f28d1aa9d19.zip
fix for setting overrides with -a
-rw-r--r--src/relx.erl6
-rw-r--r--src/rlx_cmd_args.erl29
-rw-r--r--test/rlx_command_SUITE.erl4
3 files changed, 25 insertions, 14 deletions
diff --git a/src/relx.erl b/src/relx.erl
index 769668a..a48e3dd 100644
--- a/src/relx.erl
+++ b/src/relx.erl
@@ -118,7 +118,7 @@ do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Configs) ->
-spec do(file:name(), atom(), string(), [goal()], [file:name()],
ec_cmd_log:log_level(), [file:name()], [{atom(), file:name()}], file:name() | undefined) ->
ok | error() | {ok, rlx_state:t()}.
-do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Overrides, Config) ->
+do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Overrides, Config) ->
do([{relname, RelName},
{relvsn, RelVsn},
{goals, Goals},
@@ -199,7 +199,7 @@ opt_spec_list() ->
"Verbosity level, maybe between 0 and 3"},
{dev_mode, $d, "dev-mode", {boolean, false},
"Symlink the applications and configuration into the release instead of copying"},
- {override_app, $a, "override_app", string,
+ {override, $a, "override", string,
"Provide an app name and a directory to override in the form <appname>:<app directory>"},
{config, $c, "config", {string, ""}, "The path to a config file"},
{overlay_vars, undefined, "overlay_vars", string, "Path to a file of overlay variables"},
@@ -258,7 +258,7 @@ handle_output(_State, command_line, _) ->
handle_output(_State, api, Result) ->
Result.
-run_providers(ConfigProvider, Providers, State0) ->
+run_providers(ConfigProvider, Providers, State0) ->
case Providers of
[ConfigProvider | Rest] ->
%% IF the config provider is still the first provider do not run it
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl
index 9233db9..f8aebf9 100644
--- a/src/rlx_cmd_args.erl
+++ b/src/rlx_cmd_args.erl
@@ -41,7 +41,7 @@ args2state(Opts, Targets) ->
{ok, CommandLineConfig} ->
RelName = rlx_util:to_atom(proplists:get_value(relname, Opts, undefined)),
RelVsn = proplists:get_value(relvsn, Opts, undefined),
- handle_config(Opts, AtomizedTargets,
+ handle_config(Opts, AtomizedTargets,
[{default_release, {RelName, RelVsn}} | CommandLineConfig])
end;
Error ->
@@ -131,8 +131,8 @@ validate_config(Config) ->
?RLX_ERROR({invalid_config_file, Config})
end.
-run_creates(Opts) ->
- try
+run_creates(Opts) ->
+ try
Conf = lists:flatten(lists:foldl(fun(X, Acc) ->
[create(X, Opts) | Acc]
end, [], proplists:get_keys(Opts))),
@@ -141,7 +141,7 @@ run_creates(Opts) ->
throw:E ->
E
end.
-
+
create(log_level, Opts) ->
LogLevel = proplists:get_value(log_level, Opts, 0),
if
@@ -149,7 +149,7 @@ create(log_level, Opts) ->
{log, ec_cmd_log:new(LogLevel, command_line)};
true ->
throw(?RLX_ERROR({invalid_log_level, LogLevel}))
- end;
+ end;
create(goal, Opts) ->
Goals = proplists:get_value(goals, Opts, []) ++
proplists:get_all_values(goal, Opts),
@@ -168,12 +168,21 @@ create(goals, Opts) ->
{ok, Specs} ->
{goals, Specs}
end;
+create(override, Opts) ->
+ Overrides = proplists:get_value(overrides, Opts, []) ++
+ proplists:get_all_values(override, Opts),
+ case convert_overrides(Overrides, []) of
+ {ok, Overrides2} ->
+ {overrides, Overrides2};
+ Error ->
+ throw(Error)
+ end;
create(overrides, Opts) ->
- Overrides = proplists:get_all_values(override, Opts) ++
- proplists:get_value(overrides, Opts, []),
+ Overrides = proplists:get_value(overrides, Opts, []) ++
+ proplists:get_all_values(override, Opts),
case convert_overrides(Overrides, []) of
- {ok, Overrides} ->
- {overrides, Overrides};
+ {ok, Overrides2} ->
+ {overrides, Overrides2};
Error ->
throw(Error)
end;
@@ -275,7 +284,7 @@ convert_overrides([Override | Rest], Acc)
when erlang:is_list(Override); erlang:is_binary(Override) ->
case re:split(Override, ":") of
[AppName, AppDir] ->
- convert_overrides(Rest, [{erlang:iolist_to_binary(AppName), AppDir} | Acc]);
+ convert_overrides(Rest, [{rlx_util:to_atom(AppName), AppDir} | Acc]);
_ ->
?RLX_ERROR({failed_to_parse_override, Override})
end;
diff --git a/test/rlx_command_SUITE.erl b/test/rlx_command_SUITE.erl
index c34ed88..26783ff 100644
--- a/test/rlx_command_SUITE.erl
+++ b/test/rlx_command_SUITE.erl
@@ -58,11 +58,13 @@ normal_passing_case(Config) ->
RelName = "foo-release",
RelVsn = "33.222",
CmdLine = ["-V", LogLevel, "-g",Goal1,"-g",Goal2, "-l", Lib1, "-l", Lib2,
- "-n", RelName, "-v", RelVsn, "-o", Outdir],
+ "-n", RelName, "-v", RelVsn, "-o", Outdir, "-a", "lib1:"++binary_to_list(Lib1)],
{ok, {Opts, Targets}} = getopt:parse(relx:opt_spec_list(), CmdLine),
{ok, State} = rlx_cmd_args:args2state(Opts, Targets),
{ConfigProvider, {ok, State1}} = rlx_provider:new(rlx_prv_config, State),
{ok, State2} = rlx_provider:do(ConfigProvider, State1),
+ Overrides = rlx_state:overrides(State2),
+ ?assertMatch([{lib1, Lib1}], Overrides),
?assertMatch([Lib1, Lib2],
rlx_state:lib_dirs(State2)),
?assertMatch(Outdir, rlx_state:base_output_dir(State2)),