ku1ik / rainbow

Ruby gem for colorizing printed text on ANSI terminals
MIT License
813 stars 68 forks source link

Add an easy way to enable/disable for a block #133

Open TylerRick opened 2 days ago

TylerRick commented 2 days ago

My use case is for methods that I want to add a color option (like many CLI commands have), so that I can easily toggle color as needed. Example:

def inspect(color: Rainbow.enabled)
  Rainbow.with_enabled(color) do
    Rainbow('...').red
  end
end