aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Sloughter <[email protected]>2016-02-16 11:51:01 -0600
committerTristan Sloughter <[email protected]>2016-02-16 11:51:01 -0600
commitb373b201e6d2c55333ef10de8db7c1d06fa65191 (patch)
tree310e157df4a595046ca96a9b87fad094f674186b
parentef1921571bc5e4c3aec4d3b3f36b62efba01c3fd (diff)
parent0a029824e2d767b71f5f75f15b25861c49df1889 (diff)
downloadrelx-b373b201e6d2c55333ef10de8db7c1d06fa65191.tar.gz
relx-b373b201e6d2c55333ef10de8db7c1d06fa65191.tar.bz2
relx-b373b201e6d2c55333ef10de8db7c1d06fa65191.zip
Merge pull request #446 from project-fifo/arghv3.16.0
Add low / high color mode
-rw-r--r--src/rlx_cmd_args.erl4
-rw-r--r--src/rlx_state.erl4
-rw-r--r--src/rlx_util.erl21
3 files changed, 26 insertions, 3 deletions
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl
index b64c05d..7f3f39b 100644
--- a/src/rlx_cmd_args.erl
+++ b/src/rlx_cmd_args.erl
@@ -25,7 +25,6 @@
format_error/1]).
-include("relx.hrl").
-
%%============================================================================
%% API
%%============================================================================
@@ -137,7 +136,8 @@ create(log_level, Opts) ->
LogLevel = proplists:get_value(log_level, Opts, 0),
if
LogLevel >= 0, LogLevel =< 3 ->
- {log, ec_cmd_log:new(LogLevel, command_line)};
+ {log, ec_cmd_log:new(LogLevel, command_line,
+ rlx_util:intensity())};
true ->
throw(?RLX_ERROR({invalid_log_level, LogLevel}))
end;
diff --git a/src/rlx_state.erl b/src/rlx_state.erl
index 42cd730..a26546d 100644
--- a/src/rlx_state.erl
+++ b/src/rlx_state.erl
@@ -146,7 +146,9 @@ new(Config, CommandLineConfig, Targets)
{ok, Root} = file:get_cwd(),
Caller = proplists:get_value(caller, CommandLineConfig, api),
- Log = proplists:get_value(log, CommandLineConfig, ec_cmd_log:new(error, Caller)),
+ Log = proplists:get_value(
+ log, CommandLineConfig,
+ ec_cmd_log:new(error, Caller, rlx_util:intensity())),
State0 = #state_t{log=Log,
config_file=Config,
cli_args=CommandLineConfig,
diff --git a/src/rlx_util.erl b/src/rlx_util.erl
index 9b86ad3..c4251d4 100644
--- a/src/rlx_util.erl
+++ b/src/rlx_util.erl
@@ -38,8 +38,10 @@
load_file/3,
template_files/0,
escript_foldl/3,
+ intensity/0,
symlink_or_copy/2]).
+-define(DFLT_INTENSITY, high).
-define(ONE_LEVEL_INDENT, " ").
%%============================================================================
%% types
@@ -297,6 +299,25 @@ cp_r_win32(Source,Dest) ->
end, filelib:wildcard(Source)),
ok.
+%% @doc Returns the color intensity, we first check the application envorinment
+%% if that is not set we check the environment variable RELX_COLOR.
+intensity() ->
+ case application:get_env(relx, color_intensity) of
+ undefined ->
+ R = case os:getenv("RELX_COLOR") of
+ "high" ->
+ high;
+ "low" ->
+ low;
+ _ ->
+ ?DFLT_INTENSITY
+ end,
+ application:set_env(relx, color_intensity, R),
+ R;
+ {ok, Mode} ->
+ Mode
+ end.
+
%%%===================================================================
%%% Test Functions
%%%===================================================================