diff --git a/bin/elixir b/bin/elixir index 9de16cc6365..3c17c020198 100755 --- a/bin/elixir +++ b/bin/elixir @@ -18,6 +18,7 @@ Usage: $(basename "$0") [options] [.exs file] [data] -pz "PATH" Appends the given path to Erlang code path (*) -v, --version Prints Erlang/OTP and Elixir versions (standalone) + --color BOOL Enables or disables ANSI coloring --erl "SWITCHES" Switches to be passed down to Erlang (*) --eval "COMMAND" Evaluates the given command, same as -e (*) --logger-otp-reports BOOL Enables or disables OTP reporting @@ -114,7 +115,7 @@ while [ $I -le $LENGTH ]; do -v|--no-halt) C=1 ;; - -e|-r|-pr|-pa|-pz|--eval|--remsh|--dot-iex|--dbg) + -e|-r|-pr|-pa|-pz|--eval|--remsh|--dot-iex|--dbg|--color) C=2 ;; --rpc-eval) diff --git a/bin/elixir.bat b/bin/elixir.bat index bd7a1856a20..d2272b20a29 100644 --- a/bin/elixir.bat +++ b/bin/elixir.bat @@ -24,6 +24,7 @@ echo -pa "PATH" Prepends the given path to Erlang code path echo -pz "PATH" Appends the given path to Erlang code path (*) echo -v, --version Prints Erlang/OTP and Elixir versions (standalone) echo. +echo --color BOOL Enables or disables ANSI coloring echo --erl "SWITCHES" Switches to be passed down to Erlang (*) echo --eval "COMMAND" Evaluates the given command, same as -e (*) echo --logger-otp-reports BOOL Enables or disables OTP reporting @@ -110,6 +111,7 @@ if ""==!par:--no-halt=! (goto startloop) if ""==!par:--remsh=! (shift && goto startloop) if ""==!par:--dot-iex=! (shift && goto startloop) if ""==!par:--dbg=! (shift && goto startloop) +if ""==!par:--color=! (shift && goto startloop) rem ******* ERLANG PARAMETERS ********************** if ""==!par:--boot=! (set "parsErlang=!parsErlang! -boot "%~1"" && shift && goto startloop) if ""==!par:--boot-var=! (set "parsErlang=!parsErlang! -boot_var "%~1" "%~2"" && shift && shift && goto startloop) diff --git a/bin/elixir.ps1 b/bin/elixir.ps1 index 7e6bafb4c9b..61b7ccdf091 100755 --- a/bin/elixir.ps1 +++ b/bin/elixir.ps1 @@ -26,6 +26,7 @@ Usage: $scriptName [options] [.exs file] [data] -pz "PATH" Appends the given path to Erlang code path (*) -v, --version Prints Erlang/OTP and Elixir versions (standalone) + --color Enables or disables ANSI coloring --erl "SWITCHES" Switches to be passed down to Erlang (*) --eval "COMMAND" Evaluates the given command, same as -e (*) --logger-otp-reports BOOL Enables or disables OTP reporting @@ -106,7 +107,7 @@ $runErlLog = $null $private:arg = $allArgs[$i] switch -exact ($arg) { - { $_ -in @("-e", "-r", "-pr", "-pa", "-pz", "--eval", "--remsh", "--dot-iex", "--dbg") } { + { $_ -in @("-e", "-r", "-pr", "-pa", "-pz", "--eval", "--remsh", "--dot-iex", "--dbg", "--color") } { ++$i break } diff --git a/lib/elixir/lib/kernel/cli.ex b/lib/elixir/lib/kernel/cli.ex index 096c84cfc7d..be1b9d0c102 100644 --- a/lib/elixir/lib/kernel/cli.ex +++ b/lib/elixir/lib/kernel/cli.ex @@ -295,6 +295,24 @@ defmodule Kernel.CLI do parse_argv(t, %{config | commands: [{:parallel_require, h} | config.commands]}) end + defp parse_argv([~c"--color", value | t], config) do + config = + case value do + ~c"true" -> + Application.put_env(:elixir, :ansi_enabled, true) + config + + ~c"false" -> + Application.put_env(:elixir, :ansi_enabled, false) + config + + _ -> + %{config | errors: ["--color : must be a boolean" | config.errors]} + end + + parse_argv(t, config) + end + ## Compiler defp parse_argv([~c"-o", h | t], %{mode: :elixirc} = config) do