-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Colour output only when needed #90
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This currently breaks when run in --verbose
mode:
** (ArgumentError) argument error
:erlang.bit_size([:light_magenta, ":browser"])
(sobelow 0.11.1) lib/sobelow/print.ex:217: anonymous fn/3 in Sobelow.Print.print_code/2
(elixir 1.11.4) lib/enum.ex:1508: anonymous fn/2 in Enum.map_join/3
(elixir 1.11.4) lib/enum.ex:3449: Enum.map_intersperse_list/3
(elixir 1.11.4) lib/enum.ex:1508: Enum.map_join/3
(elixir 1.11.4) lib/macro.ex:1216: Macro.call_to_string_with_args/3
(elixir 1.11.4) lib/macro.ex:970: Macro.to_string/2
(sobelow 0.11.1) lib/sobelow/print.ex:214: Sobelow.Print.print_code/2
@@ -2,6 +2,8 @@ defmodule Sobelow.Print do | |||
@moduledoc false | |||
alias Sobelow.{Finding, Parse} | |||
|
|||
defp puts(data), do: data |> IO.ANSI.format() |> IO.puts() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a flag to toggle ANSI output that defaults to true
, and works something like...
defp puts(data), do: data |> IO.ANSI.format(ansi?) |> IO.puts()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One can use NO_COLOR=1 mix sobelow
, Elixir support that environment variable OOtB since 1.10. For earlier versions it can be done by ERL_FLAGS="-elixir ansi_enabled false" mix sobelow
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that, as-is, output isn't colored by default when Sobelow is installed as an escript.
e1cc229
to
7e897ca
Compare
Fixed that error. |
@hauleth I know it's been some time since this MR, but were you interested in getting this over the finish line? From what I can tell, the last bit of work for this is the flag to toggle the ANSI output that Griffin first mentioned. |
Closing due to staleness - happy to reopen later / fold the changes into a new PR if someone stumbles upon this and desires this feature. |
Close #82