diff options
author | Eric Merritt <[email protected]> | 2013-09-20 15:29:30 -0700 |
---|---|---|
committer | Eric Merritt <[email protected]> | 2013-09-20 15:29:30 -0700 |
commit | 8da020ccdccc9da37d8accaabe9fab0ab1e825dd (patch) | |
tree | f01a4e30515c87cd7e6a8e38c010b83806cda105 /src/rlx_cmd_args.erl | |
parent | a23fc9028f1914f7dc680a443e35cf47d347365d (diff) | |
parent | 6df9d493655775677400ca0348de747d90305256 (diff) | |
download | relx-8da020ccdccc9da37d8accaabe9fab0ab1e825dd.tar.gz relx-8da020ccdccc9da37d8accaabe9fab0ab1e825dd.tar.bz2 relx-8da020ccdccc9da37d8accaabe9fab0ab1e825dd.zip |
Merge pull request #44 from tsloughter/master
allow template for sys.config and vm.args add lib_dirs config option
Diffstat (limited to 'src/rlx_cmd_args.erl')
-rw-r--r-- | src/rlx_cmd_args.erl | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl index d144953..619163a 100644 --- a/src/rlx_cmd_args.erl +++ b/src/rlx_cmd_args.erl @@ -64,7 +64,9 @@ format_error({invalid_option_arg, Arg}) -> {lib_dir, LibDir} -> io_lib:format("Invalid Library Directory argument -n ~p~n", [LibDir]); {log_level, LogLevel} -> - io_lib:format("Invalid Library Directory argument -n ~p~n", [LogLevel]) + io_lib:format("Invalid Log Level argument -n ~p~n", [LogLevel]); + {path, Path} -> + 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]); @@ -261,20 +263,34 @@ create_upfrom(Opts, Acc) -> create_caller(Opts, Acc) -> case proplists:get_value(caller, Opts, api) of "command_line" -> - {ok, [{caller, command_line} | Acc]}; + create_paths(Opts, [{caller, command_line} | Acc]); "commandline" -> - {ok, [{caller, command_line} | Acc]}; + create_paths(Opts, [{caller, command_line} | Acc]); "api" -> - {ok, [{caller, api} | Acc]}; + create_paths(Opts, [{caller, api} | Acc]); api -> - {ok, [{caller, api} | Acc]}; + create_paths(Opts, [{caller, api} | Acc]); commandline -> - {ok, [{caller, command_line} | Acc]}; + create_paths(Opts, [{caller, command_line} | Acc]); command_line -> - {ok, [{caller, command_line} | Acc]}; + create_paths(Opts, [{caller, command_line} | Acc]); Caller -> ?RLX_ERROR({invalid_caller, Caller}) end. + +-spec create_paths([getopt:option()], rlx_state:cmd_args()) -> + {ok, rlx_state:cmd_args()} | relx:error(). +create_paths(Opts, Acc) -> + Dirs = proplists:get_all_values(path, Opts) ++ + proplists:get_value(paths, Opts, []), + case check_lib_dirs(Dirs) of + Error = {error, _} -> + Error; + ok -> + code:add_pathsa([filename:absname(Path) || Path <- Dirs]), + {ok, Acc} + end. + -spec check_lib_dirs([string()]) -> ok | relx:error(). check_lib_dirs([]) -> ok; |