通过 rebar shell 将 args 传递给 erl?
Pass args through rebar shell to erl?
我正在使用 "rebar shell" 来测试我的应用程序。这记录为:
Start a shell with project and deps preloaded similar to
'erl -pa ebin -pa deps/*/ebin'.
如何向 'erl' 的底层调用添加额外的参数?为了
例如,我想添加特定于应用程序的环境变量和
运行一个Module/Function。我想调用类似的东西:
erl -pa ebin -pa deps/*/ebin -browser_spy browser_exe "/my/dir" -run bs_example test
(我希望 code:priv_dir 像使用钢筋 shell 时那样工作,
上面的 'erl' 命令不执行此操作)。
你不能
rebar shell
实际上不执行 erl ...
命令,而只是试图 复制其行为.
实际上,通过添加 code:add_pathz
路径,钢筋只是将自己变成 shell 并模仿 -pa
有关实施细节,请参阅 here:
shell(_Config, _AppFile) ->
true = code:add_pathz(rebar_utils:ebin_dir()),
%% scan all processes for any with references to the old user and save them to
%% update later
NeedsUpdate = [Pid || Pid <- erlang:processes(),
proplists:get_value(group_leader, erlang:process_info(Pid)) == whereis(user)
],
%% terminate the current user
ok = supervisor:terminate_child(kernel_sup, user),
%% start a new shell (this also starts a new user under the correct group)
_ = user_drv:start(),
%% wait until user_drv and user have been registered (max 3 seconds)
ok = wait_until_user_started(3000),
%% set any process that had a reference to the old user's group leader to the
%% new user process
_ = [erlang:group_leader(whereis(user), Pid) || Pid <- NeedsUpdate],
%% enable error_logger's tty output
ok = error_logger:swap_handler(tty),
%% disable the simple error_logger (which may have been added multiple
%% times). removes at most the error_logger added by init and the
%% error_logger added by the tty handler
ok = remove_error_handler(3),
%% this call never returns (until user quits shell)
timer:sleep(infinity).
我正在使用 "rebar shell" 来测试我的应用程序。这记录为:
Start a shell with project and deps preloaded similar to
'erl -pa ebin -pa deps/*/ebin'.
如何向 'erl' 的底层调用添加额外的参数?为了 例如,我想添加特定于应用程序的环境变量和 运行一个Module/Function。我想调用类似的东西:
erl -pa ebin -pa deps/*/ebin -browser_spy browser_exe "/my/dir" -run bs_example test
(我希望 code:priv_dir 像使用钢筋 shell 时那样工作, 上面的 'erl' 命令不执行此操作)。
你不能
rebar shell
实际上不执行 erl ...
命令,而只是试图 复制其行为.
实际上,通过添加 code:add_pathz
-pa
有关实施细节,请参阅 here:
shell(_Config, _AppFile) -> true = code:add_pathz(rebar_utils:ebin_dir()), %% scan all processes for any with references to the old user and save them to %% update later NeedsUpdate = [Pid || Pid <- erlang:processes(), proplists:get_value(group_leader, erlang:process_info(Pid)) == whereis(user) ], %% terminate the current user ok = supervisor:terminate_child(kernel_sup, user), %% start a new shell (this also starts a new user under the correct group) _ = user_drv:start(), %% wait until user_drv and user have been registered (max 3 seconds) ok = wait_until_user_started(3000), %% set any process that had a reference to the old user's group leader to the %% new user process _ = [erlang:group_leader(whereis(user), Pid) || Pid <- NeedsUpdate], %% enable error_logger's tty output ok = error_logger:swap_handler(tty), %% disable the simple error_logger (which may have been added multiple %% times). removes at most the error_logger added by init and the %% error_logger added by the tty handler ok = remove_error_handler(3), %% this call never returns (until user quits shell) timer:sleep(infinity).