summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <tristan.sloughter@gmail.com>2014-12-02 15:56:18 -0600
committerTristan Sloughter <tristan.sloughter@gmail.com>2014-12-02 15:56:18 -0600
commitda91aa3073050644d104455266f72c22fa57c73f (patch)
tree51c313e04328ebda41327b2dae3981f3385af37b
parent3b2d9ba8c81a41ae5cd554a3f50283e713e191c8 (diff)
parentc3d05b97244ab9ac3219459232cc7d4a33d84414 (diff)
Merge pull request #32 from rebar/plugin-api
API for Plugins (solves #22)
-rw-r--r--src/rebar_api.erl31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/rebar_api.erl b/src/rebar_api.erl
new file mode 100644
index 0000000..c217b85
--- /dev/null
+++ b/src/rebar_api.erl
@@ -0,0 +1,31 @@
+%%% Packages rebar.hrl features and macros into a more generic API
+%%% that can be used by plugin builders.
+-module(rebar_api).
+-include("rebar.hrl").
+-export([abort/0, abort/2,
+ console/2,
+ debug/2, info/2, warn/2, error/2]).
+-export_type([rebar_dict/0, rebar_digraph/0]).
+
+%%%%%%%%%%%%%%%%%%%%%%%
+%%% Error reporting %%%
+%%%%%%%%%%%%%%%%%%%%%%%
+
+%% @doc Interrupts program flow
+abort() -> ?FAIL.
+
+%% @doc like {@link error/2}, except it also raises an
+%% exception to interrupt program flow.
+abort(Str, Args) -> ?ABORT(Str, Args).
+
+%% @doc Prints to the console, including a newline
+console(Str, Args) -> ?CONSOLE(Str, Args).
+
+%% @doc logs with severity `debug'
+debug(Str, Args) -> ?DEBUG(Str, Args).
+%% @doc logs with severity `info'
+info(Str, Args) -> ?INFO(Str, Args).
+%% @doc logs with severity `warn'
+warn(Str, Args) -> ?WARN(Str, Args).
+%% @doc logs with severity `error'
+error(Str, Args) -> ?ERROR(Str, Args).