summaryrefslogtreecommitdiff
path: root/priv/templates/plugin.erl
blob: abf4648a7ea981b230e56bd4ca4b35df83f2739c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-module({{name}}).
-behaviour(provider).

-export([init/1, do/1, format_error/1]).

-define(PROVIDER, {{name}}).
-define(DEPS, [app_discovery]).

%% ===================================================================
%% Public API
%% ===================================================================
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
init(State) ->
    Provider = providers:create([
            {name, ?PROVIDER},            % The 'user friendly' name of the task
            {module, ?MODULE},            % The module implementation of the task
            {bare, true},                 % The task can be run by the user, always true
            {deps, ?DEPS},                % The list of dependencies
            {example, "rebar3 {{name}}"}, % How to use the plugin
            {opts, []},                   % list of options understood by the plugin
            {short_desc, "{{desc}}"},
            {desc, "{{desc}}"}
    ]),
    {ok, rebar_state:add_provider(State, Provider)}.


-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
    {ok, State}.

-spec format_error(any()) ->  iolist().
format_error(Reason) ->
    io_lib:format("~p", [Reason]).