aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric <[email protected]>2013-01-04 09:55:22 -0500
committerEric <[email protected]>2013-01-04 09:55:22 -0500
commit344fa86b23205eebc3233cf9c69a8e9e145714ac (patch)
tree0d55daed98161161d58ecd39722adab7c12d4210 /src
parentbb1fbe04e7f44b7b88176cc26537541330248a51 (diff)
downloadrelx-344fa86b23205eebc3233cf9c69a8e9e145714ac.tar.gz
relx-344fa86b23205eebc3233cf9c69a8e9e145714ac.tar.bz2
relx-344fa86b23205eebc3233cf9c69a8e9e145714ac.zip
minor format refactoring
Diffstat (limited to 'src')
-rw-r--r--src/rcl_log.erl11
-rw-r--r--src/relcool.erl32
2 files changed, 30 insertions, 13 deletions
diff --git a/src/rcl_log.erl b/src/rcl_log.erl
index a5fb43a..a24b1c0 100644
--- a/src/rcl_log.erl
+++ b/src/rcl_log.erl
@@ -36,6 +36,7 @@
format/1]).
-export_type([int_log_level/0,
+ atom_log_level/0,
log_level/0,
log_fun/0,
t/0]).
@@ -46,10 +47,14 @@
%% types
%%============================================================================
+-type log_level() :: int_log_level() | atom_log_level().
+
-type int_log_level() :: 0..2.
+
%% Why no warn? because for our purposes there is no difference between error
%% and warn
--type log_level() :: error | info | debug.
+-type atom_log_level() :: error | info | debug.
+
-opaque t() :: {?MODULE, int_log_level()}.
-type log_fun() :: fun(() -> iolist()).
@@ -58,7 +63,7 @@
%% API
%%============================================================================
%% @doc Create a new 'log level' for the system
--spec new(int_log_level() | log_level()) -> t().
+-spec new(log_level()) -> t().
new(LogLevel) when LogLevel >= 0, LogLevel =< 2 ->
{?MODULE, LogLevel};
new(AtomLogLevel)
@@ -152,7 +157,7 @@ log_level({?MODULE, DetailLogLevel}) ->
DetailLogLevel.
%% @doc get the current log level as an atom
--spec atom_log_level(t()) -> log_level().
+-spec atom_log_level(t()) -> atom_log_level().
atom_log_level({?MODULE, ?RCL_ERROR}) ->
error;
atom_log_level({?MODULE, ?RCL_INFO}) ->
diff --git a/src/relcool.erl b/src/relcool.erl
index f240553..9fb9240 100644
--- a/src/relcool.erl
+++ b/src/relcool.erl
@@ -36,6 +36,7 @@
%%============================================================================
-type error() :: {error, {Module::module(), Reason::term()}}.
+-type goal() :: string() | binary() | rcl_depsolver:constraint().
%%============================================================================
%% API
@@ -60,9 +61,12 @@ main(Args) ->
%% @param LibDirs - The library dirs that should be used for the system
%% @param OutputDir - The directory where the release should be built to
%% @param Configs - The list of config files for the system
-do(RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Configs) ->
+-spec do(atom(), string(), [goal()], [file:name()], rcl_log:log_level(),
+ [file:name()], file:name()) ->
+ ok | error() | {ok, rcl_state:t()}.
+do(RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Config) ->
{ok, Cwd} = file:get_cwd(),
- do(Cwd, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, [], Configs).
+ do(Cwd, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, [], Config).
%% @doc provides an API to run the Relcool process from erlang applications
%%
@@ -74,6 +78,9 @@ do(RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Configs) ->
%% @param LibDirs - The library dirs that should be used for the system
%% @param OutputDir - The directory where the release should be built to
%% @param Configs - The list of config files for the system
+-spec do(file:name(), atom(), string(), [goal()], [file:name()],
+ rcl_log:log_level(), [file:name()], file:name()) ->
+ ok | error() | {ok, rcl_state:t()}.
do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Configs) ->
do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, [], Configs).
@@ -88,6 +95,9 @@ do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Configs) ->
%% @param OutputDir - The directory where the release should be built to
%% @param Overrides - A list of overrides for the system
%% @param Configs - The list of config files for the system
+-spec do(file:name(), atom(), string(), [goal()], [file:name()],
+ rcl_log:log_level(), [file:name()], [{atom(), file:name()}], file:name()) ->
+ ok | error() | {ok, rcl_state:t()}.
do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Overrides, Config) ->
State = rcl_state:new([{relname, RelName},
{relvsn, RelVsn},
@@ -104,13 +114,17 @@ do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Overrides, Con
-spec opt_spec_list() -> [getopt:option_spec()].
opt_spec_list() ->
[
- {relname, $n, "relname", string, "Specify the name for the release that will be generated"},
+ {relname, $n, "relname", string,
+ "Specify the name for the release that will be generated"},
{relvsn, $v, "relvsn", string, "Specify the version for the release"},
- {goals, $g, "goal", string, "Specify a target constraint on the system. These are "
- "usually the OTP"},
- {output_dir, $o, "output-dir", string, "The output directory for the release. This is `./` by default."},
- {lib_dir, $l, "lib-dir", string, "Additional dirs that should be searched for OTP Apps"},
- {log_level, $V, "verbose", {integer, 0}, "Verbosity level, maybe between 0 and 2"},
+ {goals, $g, "goal", string,
+ "Specify a target constraint on the system. These are usually the OTP"},
+ {output_dir, $o, "output-dir", string,
+ "The output directory for the release. This is `./` by default."},
+ {lib_dir, $l, "lib-dir", string,
+ "Additional dirs that should be searched for OTP Apps"},
+ {log_level, $V, "verbose", {integer, 0},
+ "Verbosity level, maybe between 0 and 2"},
{root_dir, $r, "root", string, "The project root directory"}].
-spec format_error(Reason::term()) -> iolist().
@@ -120,7 +134,6 @@ format_error({invalid_return_value, Provider, Value}) ->
format_error({error, {Module, Reason}}) ->
io_lib:format("~s~n", [Module:format_error(Reason)]).
-
%%============================================================================
%% internal api
%%============================================================================
@@ -187,7 +200,6 @@ run_provider(Provider, {ok, State0}) ->
usage() ->
getopt:usage(opt_spec_list(), "relcool", "[*release-specification-file*]").
-
-spec report_error(rcl_state:t(), error()) -> none() | error().
report_error(State, Error) ->
io:format(format_error(Error)),