aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/relx.erl6
-rw-r--r--src/rlx_cmd_args.erl4
-rw-r--r--src/rlx_config.erl28
-rw-r--r--src/rlx_prv_overlay.erl7
-rw-r--r--src/rlx_state.erl4
5 files changed, 32 insertions, 17 deletions
diff --git a/src/relx.erl b/src/relx.erl
index e9867a9..37918be 100644
--- a/src/relx.erl
+++ b/src/relx.erl
@@ -21,6 +21,7 @@
-module(relx).
-export([main/1,
+ main/2,
do/2,
do/7,
do/8,
@@ -44,6 +45,9 @@
%%============================================================================
-spec main([string()]) -> ok | error() | {ok, rlx_state:t()}.
main(Args) ->
+ main([], Args).
+
+main(ApiOptions, Args) ->
OptSpecList = opt_spec_list(),
Result = case getopt:parse(OptSpecList, Args) of
{ok, {Options, NonOptions}} ->
@@ -58,7 +62,7 @@ main(Args) ->
usage();
false ->
application:start(relx),
- do([{caller, command_line} | Options], NonOptions)
+ do(ApiOptions++[{caller, command_line} | Options], NonOptions)
end
end;
{error, Detail} ->
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl
index e117d8e..84aeca5 100644
--- a/src/rlx_cmd_args.erl
+++ b/src/rlx_cmd_args.erl
@@ -69,7 +69,7 @@ format_error({invalid_option_arg, Arg}) ->
io_lib:format("Invalid code path argument -n ~p~n", [Path])
end;
format_error({invalid_config_file, Config}) ->
- io_lib:format("Invalid configuration file specified: ~s", [Config]);
+ io_lib:format("Invalid configuration file specified: ~p", [Config]);
format_error({invalid_caller, Caller}) ->
io_lib:format("Invalid caller specified: ~s", [Caller]);
format_error({failed_to_parse, Spec}) ->
@@ -128,7 +128,7 @@ validate_config(Config) ->
true ->
{ok, filename:absname(Config)};
false ->
- ?RLX_ERROR({invalid_config_file, Config})
+ {ok, Config}
end.
run_creates(Opts) ->
diff --git a/src/rlx_config.erl b/src/rlx_config.erl
index d4acb3c..dbfe1c6 100644
--- a/src/rlx_config.erl
+++ b/src/rlx_config.erl
@@ -97,20 +97,26 @@ parent_dir([_H], Acc) ->
parent_dir([H | T], Acc) ->
parent_dir(T, [H | Acc]).
--spec load_config(file:filename(), rlx_state:t()) ->
+-spec load_config(file:filename() | proplists:proplist(), rlx_state:t()) ->
{ok, rlx_state:t()} | relx:error().
load_config(ConfigFile, State) ->
{ok, CurrentCwd} = file:get_cwd(),
- ok = file:set_cwd(filename:dirname(ConfigFile)),
- Result = case file:consult(ConfigFile) of
- {error, Reason} ->
- ?RLX_ERROR({consult, ConfigFile, Reason});
- {ok, Terms} ->
- CliTerms = rlx_state:cli_args(State),
- lists:foldl(fun load_terms/2, {ok, State}, merge_configs(CliTerms, Terms))
- end,
- ok = file:set_cwd(CurrentCwd),
- Result.
+ case filelib:is_regular(ConfigFile) of
+ true ->
+ ok = file:set_cwd(filename:dirname(ConfigFile)),
+ Result = case file:consult(ConfigFile) of
+ {error, Reason} ->
+ ?RLX_ERROR({consult, ConfigFile, Reason});
+ {ok, Terms} ->
+ CliTerms = rlx_state:cli_args(State),
+ lists:foldl(fun load_terms/2, {ok, State}, merge_configs(CliTerms, Terms))
+ end,
+ ok = file:set_cwd(CurrentCwd),
+ Result;
+ false ->
+ CliTerms = rlx_state:cli_args(State),
+ lists:foldl(fun load_terms/2, {ok, State}, merge_configs(CliTerms, ConfigFile))
+ end.
-spec load_terms(term(), {ok, rlx_state:t()} | relx:error()) ->
{ok, rlx_state:t()} | relx:error().
diff --git a/src/rlx_prv_overlay.erl b/src/rlx_prv_overlay.erl
index 4cbbf31..f7e2be8 100644
--- a/src/rlx_prv_overlay.erl
+++ b/src/rlx_prv_overlay.erl
@@ -377,7 +377,12 @@ get_relative_root(State) ->
[] ->
rlx_state:root_dir(State);
Config ->
- filename:dirname(Config)
+ case filelib:is_regular(Config) of
+ true ->
+ filename:dirname(Config);
+ false ->
+ rlx_state:root_dir(State)
+ end
end.
-spec is_directory(file:name(), file:name()) -> boolean().
diff --git a/src/rlx_state.erl b/src/rlx_state.erl
index 71b96f3..a25c60f 100644
--- a/src/rlx_state.erl
+++ b/src/rlx_state.erl
@@ -216,11 +216,11 @@ goals(#state_t{goals=TS}) ->
goals(State, Goals) ->
State#state_t{goals=Goals}.
--spec config_file(t()) -> file:filename() | undefined.
+-spec config_file(t()) -> file:filename() | proplists:proplist() | undefined.
config_file(#state_t{config_file=ConfigFiles}) ->
ConfigFiles.
--spec config_file(t(), file:filename() | undefined) -> t().
+-spec config_file(t(), file:filename() | proplists:proplist() | undefined) -> t().
config_file(State, ConfigFiles) ->
State#state_t{config_file=ConfigFiles}.