aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Sloughter <[email protected]>2013-10-12 12:29:57 -0500
committerTristan Sloughter <[email protected]>2013-10-12 12:29:57 -0500
commitf50f63f1cb504fc9af4f060b7e7d6c5f1c816d41 (patch)
tree4ef0d3c0b573b0d0c8459010fc37750c7bb6eba0
parent51d787c7e3da7cbfa092b8455706911749f26d45 (diff)
downloadrelx-f50f63f1cb504fc9af4f060b7e7d6c5f1c816d41.tar.gz
relx-f50f63f1cb504fc9af4f060b7e7d6c5f1c816d41.tar.bz2
relx-f50f63f1cb504fc9af4f060b7e7d6c5f1c816d41.zip
add overlay_vars command line arg
-rw-r--r--README.md1
-rw-r--r--src/relx.erl1
-rw-r--r--src/rlx_cmd_args.erl8
-rw-r--r--src/rlx_prv_config.erl4
-rw-r--r--src/rlx_state.erl10
5 files changed, 20 insertions, 4 deletions
diff --git a/README.md b/README.md
index b217052..19e2008 100644
--- a/README.md
+++ b/README.md
@@ -60,6 +60,7 @@ Options
| -V | --verbose | integer | 2 | The verbosity level between 0 and 3 |
| -a | --override_app | string | | An app name and a directory to override in the form appname:dir |
| -c | --config | string | ./relx.config | Config file path |
+| | --overlay_vars | string | | Path to a file of overlay variables |
Wiki
----
diff --git a/src/relx.erl b/src/relx.erl
index dc5b8e0..7b09751 100644
--- a/src/relx.erl
+++ b/src/relx.erl
@@ -200,6 +200,7 @@ opt_spec_list() ->
{override_app, $a, "override_app", 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"},
{version, $v, "version", undefined, "Print relx version"},
{root_dir, $r, "root", string, "The project root directory"}].
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl
index 2a0f573..e360ab8 100644
--- a/src/rlx_cmd_args.erl
+++ b/src/rlx_cmd_args.erl
@@ -246,7 +246,13 @@ create_root_dir(Opts, Acc) ->
{ok, rlx_state:cmd_args()} | relx:error().
create_disable_default_libs(Opts, Acc) ->
Def = proplists:get_value(default_libs, Opts, true),
- create_upfrom(Opts, [{default_libs, Def} | Acc]).
+ create_overlay_vars(Opts, [{default_libs, Def} | Acc]).
+
+-spec create_overlay_vars([getopt:option()], rlx_state:cmd_args()) ->
+ {ok, rlx_state:cmd_args()} | relx:error().
+create_overlay_vars(Opts, Acc) ->
+ OverlayVars = proplists:get_all_values(overlay_vars, Opts),
+ create_upfrom(Opts, [{overlay_vars, OverlayVars} | Acc]).
-spec create_upfrom([getopt:option()], rlx_state:cmd_args()) ->
{ok, rlx_state:cmd_args()} | relx:error().
diff --git a/src/rlx_prv_config.erl b/src/rlx_prv_config.erl
index dd11e65..71a2dc9 100644
--- a/src/rlx_prv_config.erl
+++ b/src/rlx_prv_config.erl
@@ -174,6 +174,10 @@ load_terms({vm_args, VmArgs}, {ok, State}) ->
{ok, rlx_state:vm_args(State, filename:absname(VmArgs))};
load_terms({sys_config, SysConfig}, {ok, State}) ->
{ok, rlx_state:sys_config(State, filename:absname(SysConfig))};
+load_terms({overlay_vars, OverlayVars}, {ok, State}) ->
+ CurrentOverlayVars = rlx_state:get(State, overlay_vars),
+ NewOverlayVars = lists:umerge(lists:usort(OverlayVars), lists:usort(CurrentOverlayVars)),
+ {ok, rlx_state:put(State, overlay_vars, NewOverlayVars)};
load_terms({Name, Value}, {ok, State})
when erlang:is_atom(Name) ->
{ok, rlx_state:put(State, Name, Value)};
diff --git a/src/rlx_state.erl b/src/rlx_state.erl
index 4c6df07..74304cc 100644
--- a/src/rlx_state.erl
+++ b/src/rlx_state.erl
@@ -134,9 +134,13 @@ new(PropList, Targets)
upfrom = proplists:get_value(upfrom, PropList, undefined),
default_configured_release={proplists:get_value(relname, PropList, undefined),
proplists:get_value(relvsn, PropList, undefined)}},
- rlx_state:put(create_logic_providers(State0),
- default_libs,
- proplists:get_value(default_libs, PropList, true)).
+ State1 = rlx_state:put(create_logic_providers(State0),
+ default_libs,
+ proplists:get_value(default_libs, PropList, true)),
+
+ rlx_state:put(create_logic_providers(State1),
+ overlay_vars,
+ proplists:get_value(overlay_vars, PropList, [])).
%% @doc the actions targeted for this system
-spec actions(t()) -> [action()].