Skip to content

Add --force-color flag

Created by: CodingItWrong

Fixes #2230 (closed) by adding a --force-color flag to use alongside --no-color, while preserving backward-compatibility with the --color flag.

Please let me know anything I can do to improve this PR! A few thoughts:

  • configuration.rb is a bit more complex than it otherwise might need to be because of --color backward compatibility, but I think it's worth it
  • Setting config.no_color = true in spec_helper.rb felt a bit dirty, but I do think the best default behavior in the specs is to not have color in the output, and that was the most reliable way I could find to accomplish that.
  • The specs that distinguish the behavior of force_color and no_color when --tty is passed can probably be removed, now that they've demonstrated that that flag doesn't affect their behavior.
  • The name of the --force-color flag gets a bit confusing with the ConfigurationOptions method force (e.g. it "forces force_color"), but I think --force-color is the best external name, and it probably doesn't make sense to consider any renaming of the internal force method just for this.
  • Reading no_color = true and no_color = false gets a bit confusing, but this wouldn't extend to end users: they just use --force-color or --no-color and get the expected result. The two different properties are needed, as I describe in the commit message for 9af8f0c, because the default behavior is different from both the force_color and no_color behavior, so there are several different states.

Merge request reports