JEG2 / highline

A higher level command-line oriented interface.
Other
1.29k stars 137 forks source link

`::add_to_color_scheme` improvement #273

Closed costa closed 3 weeks ago

costa commented 2 months ago

Hi, thanks for the useful gem. I've been using the following extension for a while, and if you like it too, I could make it into a PR or something.

class HighLine
  class << self
    def add_to_color_scheme(hash)
      old_hash = (color_scheme || {}).to_hash
      fail "Overlapping color schemes: #{old_hash.keys & hash.keys}"  unless
        (old_hash.keys & hash.keys).empty?
      self.color_scheme = ColorScheme.new(old_hash.merge hash)
    end
  end
end
abinoam commented 1 month ago

I think this addition doesn't change any previous behavior. So I would welcome a PR as it sounds a good idea. Could you please add tests along the PR? I can help you with any doubt in the code base. Sorry for taking so long to answer.