You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 line
1.2 KiB

  1. %% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
  2. %% ex: ts=4 sw=4 et
  3. -module(rebar_prv_state).
  4. -behaviour(provider).
  5. -export([init/1,
  6. do/1,
  7. format_error/1]).
  8. -include("rebar.hrl").
  9. -define(PROVIDER, state).
  10. -define(DEPS, []).
  11. %% ===================================================================
  12. %% Public API
  13. %% ===================================================================
  14. -spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
  15. init(State) ->
  16. Provider = providers:create(
  17. [{name, ?PROVIDER},
  18. {module, ?MODULE},
  19. {bare, false},
  20. {deps, ?DEPS},
  21. {example, "rebar3 state"},
  22. {short_desc, "Print current configuration state"},
  23. {desc, "Display rebar configuration for debugging purpose"},
  24. {opts, []}]),
  25. State1 = rebar_state:add_provider(State, Provider),
  26. {ok, State1}.
  27. -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
  28. do(State) ->
  29. L = rebar_state:to_list(State),
  30. ?CONSOLE("State:", []),
  31. [?CONSOLE(" ~w: ~p", [K, V]) || {K,V} <- L],
  32. {ok, State}.
  33. -spec format_error(any()) -> iolist().
  34. format_error(Reason) ->
  35. io_lib:format("~p", [Reason]).