From e9a3396e56679a11ac1caa3b47f1f196f0307d72 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 27 Sep 2014 14:12:11 -0500 Subject: return error messages from providers --- src/rebar_prv_packages.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rebar_prv_packages.erl') diff --git a/src/rebar_prv_packages.erl b/src/rebar_prv_packages.erl index 79c1cd2..3349287 100644 --- a/src/rebar_prv_packages.erl +++ b/src/rebar_prv_packages.erl @@ -22,7 +22,7 @@ init(State) -> 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), -- cgit v1.1 From b37a5ae611aaf6b84a046fbe716f40c2aa8c75d8 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 3 Oct 2014 06:33:33 -0500 Subject: move providers to separate app --- src/rebar_prv_packages.erl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/rebar_prv_packages.erl') diff --git a/src/rebar_prv_packages.erl b/src/rebar_prv_packages.erl index 3349287..6c0dd3f 100644 --- a/src/rebar_prv_packages.erl +++ b/src/rebar_prv_packages.erl @@ -1,6 +1,6 @@ -module(rebar_prv_packages). --behaviour(rebar_provider). +-behaviour(provider). -export([init/1, do/1]). @@ -12,14 +12,14 @@ -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()} | {error, string()}. -- cgit v1.1 From 1dce2d36cc75263db279abd7f282772ce0f0f3e6 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Wed, 22 Oct 2014 12:03:49 -0500 Subject: add format_error/2 provider callback to providers --- src/rebar_prv_packages.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/rebar_prv_packages.erl') diff --git a/src/rebar_prv_packages.erl b/src/rebar_prv_packages.erl index 6c0dd3f..be51833 100644 --- a/src/rebar_prv_packages.erl +++ b/src/rebar_prv_packages.erl @@ -3,7 +3,8 @@ -behaviour(provider). -export([init/1, - do/1]). + do/1, + format_error/2]). -include("rebar.hrl"). @@ -28,6 +29,10 @@ do(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), -- cgit v1.1