diff options
Diffstat (limited to 'src/rebar_shell.erl')
-rw-r--r-- | src/rebar_shell.erl | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/rebar_shell.erl b/src/rebar_shell.erl index 0220a79..b089631 100644 --- a/src/rebar_shell.erl +++ b/src/rebar_shell.erl @@ -28,9 +28,37 @@ -module(rebar_shell). -author("Kresten Krab Thorup <krab@trifork.com>"). +-behaviour(rebar_provider). + +-export([init/1, + do/1]). + -include("rebar.hrl"). --export([shell/2, info/2]). +-define(PROVIDER, shell). +-define(DEPS, [app_builder]). + +%% =================================================================== +%% Public API +%% =================================================================== + +-spec init(rebar_config:config()) -> {ok, rebar_config:config()}. +init(State) -> + State1 = rebar_config:add_provider(State, #provider{name = ?PROVIDER, + provider_impl = ?MODULE, + provides = shell, + bare = false, + deps = ?DEPS, + example = "rebar shell", + short_desc = "", + desc = "", + opts = []}), + {ok, State1}. + +-spec do(rebar_config:config()) -> {ok, rebar_config:config()} | relx:error(). +do(Config) -> + shell(), + {ok, Config}. %% NOTE: %% this is an attempt to replicate `erl -pa ./ebin -pa deps/*/ebin`. it is @@ -39,7 +67,7 @@ %% it also lacks the ctrl-c interrupt handler that `erl` features. ctrl-c will %% immediately kill the script. ctrl-g, however, works fine -shell(_Config, _AppFile) -> +shell() -> 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 @@ -88,4 +116,4 @@ wait_until_user_started(Timeout) -> %% if user is not yet registered wait a tenth of a second and try again undefined -> timer:sleep(100), wait_until_user_started(Timeout - 100); _ -> ok - end.
\ No newline at end of file + end. |