aboutsummaryrefslogtreecommitdiffstats
path: root/src/rcl_cmd_args.erl
diff options
context:
space:
mode:
authorEric <[email protected]>2012-09-10 08:23:12 -0500
committerEric <[email protected]>2012-09-10 08:23:12 -0500
commit4505d4f1ed6a7ba0d390f262bdeee9c35bc5d7a4 (patch)
tree06cb1eb4a99ce4a500a8646c503222d8aa4d2d77 /src/rcl_cmd_args.erl
parent9aab4d7a16fba5dfcf4d60b58a05cc765eca3335 (diff)
downloadrelx-4505d4f1ed6a7ba0d390f262bdeee9c35bc5d7a4.tar.gz
relx-4505d4f1ed6a7ba0d390f262bdeee9c35bc5d7a4.tar.bz2
relx-4505d4f1ed6a7ba0d390f262bdeee9c35bc5d7a4.zip
add config validation support to the system
Diffstat (limited to 'src/rcl_cmd_args.erl')
-rw-r--r--src/rcl_cmd_args.erl31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/rcl_cmd_args.erl b/src/rcl_cmd_args.erl
index 454e762..f8918c2 100644
--- a/src/rcl_cmd_args.erl
+++ b/src/rcl_cmd_args.erl
@@ -45,12 +45,39 @@ args2state({ok, {Opts, Targets}}) ->
Error = {error, _} ->
Error;
{ok, CommandLineConfig} ->
- {ok, {rcl_state:new(CommandLineConfig), Targets}}
+ case validate_configs(Targets) of
+ Error = {error, _} ->
+ Error;
+ {ok, Configs} ->
+ {ok, {rcl_state:new(CommandLineConfig, Configs), Configs}}
+ end
end.
%%%===================================================================
%%% Internal Functions
%%%===================================================================
+-spec validate_configs([file:filename()]) ->
+ {ok, [file:filename()]} | {error, Reason::term()}.
+validate_configs(Configs) ->
+ Result =
+ lists:foldl(fun(_Config, Err = {error, _}) ->
+ Err;
+ (Config, Acc) ->
+ case filelib:is_regular(Config) of
+ true ->
+ [filename:absname(Config) | Acc];
+ false ->
+ {error, {invalid_config_file, Config}}
+ end
+ end, [], Configs),
+ case Result of
+ {error, _} ->
+ Result;
+ _ ->
+ %% Order may be important so lets make sure they remain in the same
+ %% order they came in as
+ {ok, lists:reverse(Result)}
+ end.
-spec create_log([getopt:option()], rcl_state:cmd_args()) ->
{ok, rcl_state:cmd_args()} | {error, Reason::term()}.
@@ -110,7 +137,7 @@ create_lib_dirs(Opts, Acc) ->
Error = {error, _} ->
Error;
ok ->
- {ok, [{lib_dirs, Dirs} | Acc]}
+ {ok, [{lib_dirs, [filename:absname(Dir) || Dir <- Dirs]} | Acc]}
end.
-spec check_lib_dirs([string()]) -> ok | {error, {Reason::atom(), Dir::string()}}.