diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-07-01 10:20:11 -0400 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-07-01 10:20:11 -0400 |
commit | ff1079f678e0bb633ca8bc8eb96f8f7b4efd33a7 (patch) | |
tree | 68d0f49672ab05f749eb574d68aa686ff509b486 /priv/templates/provider.erl | |
parent | 619e41b916d1d121623b410a21d48e3106035788 (diff) | |
parent | ac0a8d40cdaab1a9999446afb895c1e677c6ef9c (diff) |
Merge pull request #573 from tsloughter/plugins_tpl
update plugin template to separate plugin init and providers
Diffstat (limited to 'priv/templates/provider.erl')
-rw-r--r-- | priv/templates/provider.erl | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/priv/templates/provider.erl b/priv/templates/provider.erl new file mode 100644 index 0000000..669df83 --- /dev/null +++ b/priv/templates/provider.erl @@ -0,0 +1,32 @@ +-module('{{name}}_prv'). + +-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]). |