Skip to content

Commit 2c1a836

Browse files
committed
Make --color/--no-color consistent with mix test
1 parent f29e18b commit 2c1a836

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

bin/elixir

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Usage: $(basename "$0") [options] [.exs file] [data]
1818
-pz "PATH" Appends the given path to Erlang code path (*)
1919
-v, --version Prints Erlang/OTP and Elixir versions (standalone)
2020
21-
--color BOOL Enables or disables ANSI coloring
21+
--color, --no-color Enables or disables ANSI coloring
2222
--erl "SWITCHES" Switches to be passed down to Erlang (*)
2323
--eval "COMMAND" Evaluates the given command, same as -e (*)
2424
--logger-otp-reports BOOL Enables or disables OTP reporting
@@ -112,10 +112,10 @@ while [ $I -le $LENGTH ]; do
112112
C=1
113113
MODE="iex"
114114
;;
115-
-v|--no-halt)
115+
-v|--no-halt|--color|--no-color)
116116
C=1
117117
;;
118-
-e|-r|-pr|-pa|-pz|--eval|--remsh|--dot-iex|--dbg|--color)
118+
-e|-r|-pr|-pa|-pz|--eval|--remsh|--dot-iex|--dbg)
119119
C=2
120120
;;
121121
--rpc-eval)

bin/elixir.bat

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ echo -pa "PATH" Prepends the given path to Erlang code path
2424
echo -pz "PATH" Appends the given path to Erlang code path (*)
2525
echo -v, --version Prints Erlang/OTP and Elixir versions (standalone)
2626
echo.
27-
echo --color BOOL Enables or disables ANSI coloring
27+
echo --color, --no-color Enables or disables ANSI coloring
2828
echo --erl "SWITCHES" Switches to be passed down to Erlang (*)
2929
echo --eval "COMMAND" Evaluates the given command, same as -e (*)
3030
echo --logger-otp-reports BOOL Enables or disables OTP reporting
@@ -108,10 +108,11 @@ if ""==!par:-pz=! (shift && goto startloop)
108108
if ""==!par:-v=! (goto startloop)
109109
if ""==!par:--version=! (goto startloop)
110110
if ""==!par:--no-halt=! (goto startloop)
111+
if ""==!par:--color=! (goto startloop)
112+
if ""==!par:--no-color=! (goto startloop)
111113
if ""==!par:--remsh=! (shift && goto startloop)
112114
if ""==!par:--dot-iex=! (shift && goto startloop)
113115
if ""==!par:--dbg=! (shift && goto startloop)
114-
if ""==!par:--color=! (shift && goto startloop)
115116
rem ******* ERLANG PARAMETERS **********************
116117
if ""==!par:--boot=! (set "parsErlang=!parsErlang! -boot "%~1"" && shift && goto startloop)
117118
if ""==!par:--boot-var=! (set "parsErlang=!parsErlang! -boot_var "%~1" "%~2"" && shift && shift && goto startloop)

lib/elixir/lib/kernel/cli.ex

+6-14
Original file line numberDiff line numberDiff line change
@@ -295,21 +295,13 @@ defmodule Kernel.CLI do
295295
parse_argv(t, %{config | commands: [{:parallel_require, h} | config.commands]})
296296
end
297297

298-
defp parse_argv([~c"--color", value | t], config) do
299-
config =
300-
case value do
301-
~c"true" ->
302-
Application.put_env(:elixir, :ansi_enabled, true)
303-
config
304-
305-
~c"false" ->
306-
Application.put_env(:elixir, :ansi_enabled, false)
307-
config
308-
309-
_ ->
310-
%{config | errors: ["--color : must be a boolean" | config.errors]}
311-
end
298+
defp parse_argv([~c"--color" | t], config) do
299+
Application.put_env(:elixir, :ansi_enabled, true)
300+
parse_argv(t, config)
301+
end
312302

303+
defp parse_argv([~c"--no-color" | t], config) do
304+
Application.put_env(:elixir, :ansi_enabled, true)
313305
parse_argv(t, config)
314306
end
315307

lib/mix/lib/mix/tasks/test.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ defmodule Mix.Tasks.Test do
113113
and imports (but not local functions). You can press `n` for the next line
114114
and `c` for the next test. This automatically sets `--trace`
115115
116-
* `--color` - enables color in the output
116+
* `--color` - enables color in ExUnit formatting results
117117
118118
* `--cover` - runs coverage tool. See "Coverage" section below
119119

0 commit comments

Comments
 (0)