소스 검색

Optionally allow node names to the rebar3 shell.

Helps with integration efforts, but unfortunately can't support the
'-sname' and '-name' options, only '--sname' and '--name'.
pull/473/head
Fred Hebert 10 년 전
부모
커밋
c87f2a2c73
1개의 변경된 파일30개의 추가작업 그리고 12개의 파일을 삭제
  1. +30
    -12
      src/rebar_prv_shell.erl

+ 30
- 12
src/rebar_prv_shell.erl 파일 보기

@ -57,7 +57,11 @@ init(State) ->
{desc, info()},
{opts, [{config, undefined, "config", string,
"Path to the config file to use. Defaults to the "
"sys_config defined for relx, if present."}]}
"sys_config defined for relx, if present."},
{name, undefined, "name", atom,
"Gives a long name to the node."},
{sname, undefined, "sname", atom,
"Gives a short name to the node."}]}
])
),
{ok, State1}.
@ -79,6 +83,7 @@ format_error(Reason) ->
%% immediately kill the script. ctrl-g, however, works fine
shell(State) ->
setup_name(State),
setup_paths(State),
maybe_boot_apps(State),
setup_shell(),
@ -117,17 +122,6 @@ setup_paths(State) ->
%% add project app test paths
ok = add_test_paths(State).
reread_config(State) ->
case find_config(State) of
no_config ->
ok;
ConfigList ->
_ = [application:set_env(Application, Key, Val)
|| {Application, Items} <- ConfigList,
{Key, Val} <- Items],
ok
end.
maybe_boot_apps(State) ->
case find_apps_to_boot(State) of
undefined ->
@ -140,6 +134,19 @@ maybe_boot_apps(State) ->
boot_apps(Apps)
end.
setup_name(State) ->
{Opts, _} = rebar_state:command_parsed_args(State),
case {proplists:get_value(name, Opts), proplists:get_value(sname, Opts)} of
{undefined, undefined} ->
ok;
{Name, undefined} ->
net_kernel:start([Name, longnames]);
{undefined, SName} ->
net_kernel:start([SName, shortnames]);
{_, _} ->
?ABORT("Cannot have both short and long node names defined", [])
end.
find_apps_to_boot(State) ->
%% Try the shell_apps option
case rebar_state:get(State, shell_apps, undefined) of
@ -164,6 +171,17 @@ load_apps(Apps) ->
not lists:keymember(App, 1, application:loaded_applications())],
ok.
reread_config(State) ->
case find_config(State) of
no_config ->
ok;
ConfigList ->
_ = [application:set_env(Application, Key, Val)
|| {Application, Items} <- ConfigList,
{Key, Val} <- Items],
ok
end.
boot_apps(Apps) ->
?WARN("The rebar3 shell is a development tool; to deploy "
"applications in production, consider using releases "

불러오는 중...
취소
저장