Skip to content

Commit

Permalink
Add color option tu kucumberl
Browse files Browse the repository at this point in the history
  • Loading branch information
telemaco committed Nov 20, 2012
1 parent f43edee commit f211f26
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/kucumberl_cli.erl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
rskip = [],
fdir = [],
task = runtests,
features = []
features = [],
color = true
}).

%%%===================================================================
Expand All @@ -53,6 +54,8 @@ main(Args) ->
code:add_pathsa(Conf#conf.path_a),
code:add_pathsz(Conf#conf.path_z),

kucumberl_log:set_color(Conf#conf.color),

case Conf#conf.task of
help ->
usage(OptSpecList);
Expand Down Expand Up @@ -87,7 +90,8 @@ option_spec_list() ->
{skip, $s, "skip", string, "Skip feature"},
{rskip, $r, "rskip", string, "Skip features using regexp"},
{path_a, $a, "pa", string, "Adds the specified directories to the beginning of the code path"},
{path_z, $z, "pz", string, "Adds the specified directories to the end of the code path"}
{path_z, $z, "pz", string, "Adds the specified directories to the end of the code path"},
{color, $C, "color", {boolean, true}, "Use colors or not (enabled by default)"}
].


Expand All @@ -101,6 +105,10 @@ store_conf(Conf, [I|Rest]) ->
{path_a, S} -> NewConf = Conf#conf{path_a = Conf#conf.path_a ++ [S]};
{path_z, S} -> NewConf = Conf#conf{path_z = Conf#conf.path_z ++ [S]};
{fdir, S} -> NewConf = Conf#conf{fdir = S};
{color, B} -> NewConf = case B of
true -> Conf#conf{color = true};
false -> Conf#conf{color = false}
end;
_ -> NewConf = Conf
end,
store_conf(NewConf, Rest);
Expand Down
13 changes: 13 additions & 0 deletions src/kucumberl_log.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

%% API
-export([start_link/0,
set_color/1,
init_feature/1,
init_scenario/1,
end_feature/0,
Expand Down Expand Up @@ -51,6 +52,9 @@
start_link() ->
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).

set_color(Value) ->
gen_server:call(?MODULE, {set_color, Value}).

init_feature(Feature) ->
gen_server:call(?MODULE, {init_feature, Feature}).

Expand Down Expand Up @@ -81,6 +85,15 @@ handle_call({init_feature, Feature}, _From, State) ->
print_feature_name(NewState),
{reply, ok, NewState};

handle_call({set_color, Value}, _From, State) ->
case Value of
true ->
NewState = State#state{color = true};
false ->
NewState = State#state{color = false}
end,
{reply, ok, NewState};

handle_call({end_feature}, _From, State) ->
NewState = State#state{feature = []},
{reply, ok, NewState};
Expand Down

0 comments on commit f211f26

Please sign in to comment.