Crayon
Beautiful colored strings right inside your terminal. The Crystal
way! :tada:
Installation
Add this to your application's shard.yml
:
dependencies:
crayon:
github: crystalrealm/crayon
Usage
require "crayon"
cyanOnBlack = Crayon::Crayon.new("light_cyan", "black", {
"bold" => true,
})
puts cyanOnBlack.apply("Hello from Crayon!")
You have the following color options to choose from for the foreground color:
- red
- black
- green
- yellow
- blue
- magenta
- cyan
- light_gray
- dark_gray
- light_red
- light_green
- light_yellow
- light_blue
- light_magenta
- light_cyan
- white
... and for the background:
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- light_gray
- dark_gray
- light_red
- light_green
- light_yellow
- light_blue
- light_magenta
- light_cyan
- white
API
Crayon simply with uses 1
method.
You create a new instance of Crayon::Crayon
like so:
instance = Crayon::Crayon.new(@foreground : String, @background : String, *options)
Then, you can apply the colors to any string you wish:
instance.apply("Hello, World!")
Contributing
- Fork it (https://github.com/molnarmark/crayon/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- molnarmark Mark Molnar - creator, maintainer