Current section
Files
Jump to
Current section
Files
src/rebar3_proto_plugin_prv.erl
-module(rebar3_proto_plugin_prv).
-export([init/1, do/1, format_error/1]).
-define(PROVIDER, generate).
-define(DEPS, [app_discovery]).
%% ===================================================================
%% Public API
%% ===================================================================
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
init(State) ->
Provider = providers:create([
{name, ?PROVIDER},
{namespace, proto},
{module, ?MODULE},
{bare, true},
{deps, ?DEPS},
{example, "rebar3 proto"},
{opts, []},
{short_desc, "A rebar plugin"},
{desc, "A rebar plugin"}
]),
{ok, rebar_state:add_provider(State, Provider)}.
-spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
do(State) ->
Apps = case rebar_state:current_app(State) of
undefined ->
rebar_state:project_apps(State);
AppInfo ->
[AppInfo]
end,
lists:foreach(fun(App) ->
rebar3_proto_plugin_prv_generate:generate(App, State)
end, Apps),
{ok, State}.
-spec format_error(any()) -> iolist().
format_error(Reason) ->
io_lib:format("~p", [Reason]).