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
--no-color is not available for crystal spec
#1587
Comments
Sorry for the noob question @rhysd doesn't vim support ANSI colors? |
@sdogruyol I'm sure it's not an issue of vim supporting ANSI colors, rather I think @rhysd wants to be able to parse raw spec output without having to worry about coloring characters messing with output. |
Vim doesn't support ANSI color sequences directly. As a workaround, it may be able to delete ANSI color sequence from the output. But it is not perfect because Vim can't know which color sequence is derived from compiler's output and derived from output of spec itself. Many other subcommands have I looked some compiler code. Color is controlled by instance variable |
I like this. You'd need to support it in the spec.cr program, and then pass it from the compiler into that subprogram, in case you want to tackle this :) |
@asterite adding the logic to disable colors is easy: diff --git a/src/spec/spec.cr b/src/spec/spec.cr
index ed5b3d4..f58639c 100644
--- a/src/spec/spec.cr
+++ b/src/spec/spec.cr
@@ -84,7 +84,11 @@ module Spec
# :nodoc:
def self.color(str, status)
- str.colorize(COLORS[status])
+ if color?
+ str.colorize(COLORS[status])
+ else
+ str
+ end
end
# :nodoc:
@@ -109,6 +113,17 @@ module Spec
@@aborted
end
+ @@color = true
+
+ # :nodoc:
+ def self.color=(@@color)
+ end
+
+ # :nodoc:
+ def self.color?
+ @@color
+ end
+
@@pattern = nil
# :nodoc:
@@ -191,6 +206,9 @@ OptionParser.parse! do |opts|
opts.on("--fail-fast", "abort the run on first failure") do
Spec.fail_fast = true
end
+ opts.on("--no-color", "disable color output") do
+ Spec.color = false
+ end
opts.on("--help", "show this help") do |pattern|
puts opts
exit But having problems to adding support to |
Related issue: crystal-lang#1587 Thank you @luislavena for the patch
Related issue: crystal-lang#1587 Thank you @luislavena for the patch
Related issue: crystal-lang#1587 Thank you @luislavena for the patch
When I run
I get a colored output. Here is my crystal version:
I am on OSX 10.12.6 |
@martinos, please see comment here #4292 (comment) |
I think |
It seems that the |
I ran
crystal spec --no-color
but below was output.I expected compiler to run specs and output result without ANSI colors.
I want
--no-color
because I want to run specs in Vim using vim-crystal. Is it possible to add--no-color
tocrystal spec
or is there any other workaround for this?The text was updated successfully, but these errors were encountered: