piotrmurach / tty

Toolkit for developing sleek command line apps.
https://ttytoolkit.org
MIT License
2.51k stars 79 forks source link

suggestion: banner #21

Open gurgeous opened 8 years ago

gurgeous commented 8 years ago

It would be great to support banners. We use this a lot in our scripts.

image

piotrmurach commented 8 years ago

That sounds useful, I would be interested in the api, do you have any code examples to show?

gurgeous commented 8 years ago

Sure - note that the ANSI colors are defined as constants. I'd be happy to wrap this up as a PR that uses pastel if you give me a bit of direction. :)

def banner(str, color: GREEN)
  now = Time.new.strftime("%H:%M:%S")
  s = "#{str} ".ljust(72, " ")
  puts "#{color}[#{now}] #{s}#{RESET}"
end

and usage:

banner("Factoring primes...")