summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2014-10-22 12:03:49 -0500
committerTristan Sloughter <t@crashfast.com>2014-10-22 19:02:16 -0500
commit1dce2d36cc75263db279abd7f282772ce0f0f3e6 (patch)
treef9d7df28147cfa5029e5333def25469a5809138d /src
parente5c872101fffa52741a29a3bfa06f63f51547020 (diff)
add format_error/2 provider callback to providers
Diffstat (limited to 'src')
-rw-r--r--src/rebar_prv_app_discovery.erl7
-rw-r--r--src/rebar_prv_clean.erl7
-rw-r--r--src/rebar_prv_compile.erl5
-rw-r--r--src/rebar_prv_deps.erl7
-rw-r--r--src/rebar_prv_do.erl7
-rw-r--r--src/rebar_prv_help.erl7
-rw-r--r--src/rebar_prv_install_deps.erl10
-rw-r--r--src/rebar_prv_lock.erl7
-rw-r--r--src/rebar_prv_new.erl7
-rw-r--r--src/rebar_prv_packages.erl7
-rw-r--r--src/rebar_prv_release.erl7
-rw-r--r--src/rebar_prv_shell.erl7
-rw-r--r--src/rebar_prv_tar.erl7
-rw-r--r--src/rebar_prv_test_deps.erl7
-rw-r--r--src/rebar_prv_update.erl7
-rw-r--r--src/rebar_prv_upgrade.erl7
-rw-r--r--src/rebar_prv_version.erl7
17 files changed, 103 insertions, 17 deletions
diff --git a/src/rebar_prv_app_discovery.erl b/src/rebar_prv_app_discovery.erl
index 775aa3d..e2dcf23 100644
--- a/src/rebar_prv_app_discovery.erl
+++ b/src/rebar_prv_app_discovery.erl
@@ -6,7 +6,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -34,3 +35,7 @@ do(State) ->
LibDirs = rebar_state:get(State, lib_dirs, ?DEFAULT_LIB_DIRS),
State1 = rebar_app_discover:do(State, LibDirs),
{ok, State1}.
+
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
diff --git a/src/rebar_prv_clean.erl b/src/rebar_prv_clean.erl
index 2f983f3..72b85dc 100644
--- a/src/rebar_prv_clean.erl
+++ b/src/rebar_prv_clean.erl
@@ -6,7 +6,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -37,3 +38,7 @@ do(State) ->
rebar_erlc_compiler:clean(State, ec_cnv:to_list(rebar_app_info:dir(AppInfo)))
end, ProjectApps),
{ok, State}.
+
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl
index fe0e197..30611cd 100644
--- a/src/rebar_prv_compile.erl
+++ b/src/rebar_prv_compile.erl
@@ -4,6 +4,7 @@
-export([init/1,
do/1,
+ format_error/2,
build/2]).
-include("rebar.hrl").
@@ -50,6 +51,10 @@ do(State) ->
{ok, State1}.
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
build(State, AppInfo) ->
?INFO("Compiling ~s~n", [rebar_app_info:name(AppInfo)]),
rebar_erlc_compiler:compile(State, ec_cnv:to_list(rebar_app_info:dir(AppInfo))),
diff --git a/src/rebar_prv_deps.erl b/src/rebar_prv_deps.erl
index 6ba0d3a..80122ac 100644
--- a/src/rebar_prv_deps.erl
+++ b/src/rebar_prv_deps.erl
@@ -3,7 +3,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -26,6 +27,10 @@ init(State) ->
do(State) ->
{ok, State}.
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
info(Description) ->
io_lib:format("~s.~n"
"~n"
diff --git a/src/rebar_prv_do.erl b/src/rebar_prv_do.erl
index 5f6e751..e66fdbd 100644
--- a/src/rebar_prv_do.erl
+++ b/src/rebar_prv_do.erl
@@ -6,7 +6,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -40,5 +41,9 @@ do(State) ->
rebar_core:process_command(StateAcc2, Task)
end, {ok, State}, Tasks).
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
args_to_tasks(Args) ->
[string:strip(T) || T <- string:tokens(string:join(Args, " "), ",")].
diff --git a/src/rebar_prv_help.erl b/src/rebar_prv_help.erl
index c2e1cd7..8300378 100644
--- a/src/rebar_prv_help.erl
+++ b/src/rebar_prv_help.erl
@@ -6,7 +6,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -49,6 +50,10 @@ do(State) ->
end
end.
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
%%
%% print help/usage string
%%
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl
index 2ff7f19..522420d 100644
--- a/src/rebar_prv_install_deps.erl
+++ b/src/rebar_prv_install_deps.erl
@@ -29,7 +29,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -82,6 +83,10 @@ do(State) ->
{error, Error}
end.
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
-spec get_deps_dir(rebar_state:t()) -> file:filename_all().
get_deps_dir(State) ->
BaseDir = rebar_state:get(State, base_dir, ""),
@@ -96,7 +101,8 @@ get_deps_dir(DepsDir, App) ->
handle_deps(State, Deps) ->
handle_deps(State, Deps, false).
--spec handle_deps(rebar_state:t(), [dep()], boolean() | {true, binary(), integer()}) -> {ok, rebar_state:t()}.
+-spec handle_deps(rebar_state:t(), [dep()], boolean() | {true, binary(), integer()})
+ -> {ok, rebar_state:t()}.
handle_deps(State, [], _) ->
{ok, State};
handle_deps(State, Deps, Update) ->
diff --git a/src/rebar_prv_lock.erl b/src/rebar_prv_lock.erl
index dfe04cd..32c5f1a 100644
--- a/src/rebar_prv_lock.erl
+++ b/src/rebar_prv_lock.erl
@@ -3,7 +3,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -54,5 +55,9 @@ do(State) ->
{ok, State}
end.
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
info(_) ->
"".
diff --git a/src/rebar_prv_new.erl b/src/rebar_prv_new.erl
index 3535061..2555b4d 100644
--- a/src/rebar_prv_new.erl
+++ b/src/rebar_prv_new.erl
@@ -3,7 +3,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -41,6 +42,10 @@ do(State) ->
{ok, State}
end.
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
%% ===================================================================
%% Internal functions
%% ===================================================================
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),
diff --git a/src/rebar_prv_release.erl b/src/rebar_prv_release.erl
index 6be639c..572f909 100644
--- a/src/rebar_prv_release.erl
+++ b/src/rebar_prv_release.erl
@@ -6,7 +6,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -40,3 +41,7 @@ do(State) ->
relx:main([{config, Config}], AllOptions)
end,
{ok, State}.
+
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
diff --git a/src/rebar_prv_shell.erl b/src/rebar_prv_shell.erl
index e74486d..24e357b 100644
--- a/src/rebar_prv_shell.erl
+++ b/src/rebar_prv_shell.erl
@@ -31,7 +31,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -59,6 +60,10 @@ do(Config) ->
shell(),
{ok, Config}.
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
%% NOTE:
%% this is an attempt to replicate `erl -pa ./ebin -pa deps/*/ebin`. it is
%% mostly successful but does stop and then restart the user io system to get
diff --git a/src/rebar_prv_tar.erl b/src/rebar_prv_tar.erl
index 06a4014..04a1b33 100644
--- a/src/rebar_prv_tar.erl
+++ b/src/rebar_prv_tar.erl
@@ -6,7 +6,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -38,3 +39,7 @@ do(State) ->
relx:main([{config, Config}], ["release tar"])
end,
{ok, State}.
+
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
diff --git a/src/rebar_prv_test_deps.erl b/src/rebar_prv_test_deps.erl
index b4c7250..081b210 100644
--- a/src/rebar_prv_test_deps.erl
+++ b/src/rebar_prv_test_deps.erl
@@ -3,7 +3,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -53,6 +54,10 @@ do(State) ->
{error, Error}
end.
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
%% ===================================================================
%% Internal functions
%% ===================================================================
diff --git a/src/rebar_prv_update.erl b/src/rebar_prv_update.erl
index 8ac4426..0d388c8 100644
--- a/src/rebar_prv_update.erl
+++ b/src/rebar_prv_update.erl
@@ -6,7 +6,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -45,6 +46,10 @@ do(State) ->
end,
{ok, State}.
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
url(State) ->
SystemArch = erlang:system_info(system_architecture),
ErtsVsn = erlang:system_info(version),
diff --git a/src/rebar_prv_upgrade.erl b/src/rebar_prv_upgrade.erl
index cbeec98..1668e1c 100644
--- a/src/rebar_prv_upgrade.erl
+++ b/src/rebar_prv_upgrade.erl
@@ -6,7 +6,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -48,3 +49,7 @@ do(State) ->
_ ->
{error, io_lib:format("No such dependency ~s~n", [Name])}
end.
+
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
diff --git a/src/rebar_prv_version.erl b/src/rebar_prv_version.erl
index f158b6d..1e907d1 100644
--- a/src/rebar_prv_version.erl
+++ b/src/rebar_prv_version.erl
@@ -6,7 +6,8 @@
-behaviour(provider).
-export([init/1,
- do/1]).
+ do/1,
+ format_error/2]).
-include("rebar.hrl").
@@ -34,3 +35,7 @@ init(State) ->
do(State) ->
rebar3:version(),
{ok, State}.
+
+-spec format_error(any(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.