summaryrefslogtreecommitdiff
path: root/src/rebar_prv_packages.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_prv_packages.erl')
-rw-r--r--src/rebar_prv_packages.erl27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/rebar_prv_packages.erl b/src/rebar_prv_packages.erl
index 79c1cd2..be51833 100644
--- a/src/rebar_prv_packages.erl
+++ b/src/rebar_prv_packages.erl
@@ -1,9 +1,10 @@
-module(rebar_prv_packages).
--behaviour(rebar_provider).
+-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -12,22 +13,26 @@
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
init(State) ->
- State1 = rebar_state:add_provider(State, #provider{name = ?PROVIDER,
- provider_impl = ?MODULE,
- bare = false,
- deps = ?DEPS,
- example = "rebar pkgs",
- short_desc = "List available packages.",
- desc = info("List available packages"),
- opts = []}),
+ State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER},
+ {module, ?MODULE},
+ {bare, false},
+ {deps, ?DEPS},
+ {example, "rebar pkgs"},
+ {short_desc, "List available packages."},
+ {desc, info("List available packages")},
+ {opts, []}])),
{ok, State1}.
--spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
+-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(State) ->
{Packages, _Graph} = rebar_packages:get_packages(State),
print_packages(Packages),
{ok, State}.
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
print_packages(Packages) ->
Keys = lists:keysort(1, dict:fetch_keys(Packages)),
Pkgs = merge(Keys),