README.md (3363B)
1 ![Bunt](https://raw.github.com/rrrene/bunt/master/assets/logo.png) 2 3 Enables 256 color ANSI coloring in the terminal and gives you the ability to alias colors to more semantic and application-specfic names. 4 5 6 ## Installation 7 8 It's available via Hex: 9 10 1. Add bunt to your list of dependencies in `mix.exs`: 11 12 def deps do 13 [{:bunt, "~> 0.1.0"}] 14 end 15 16 2. Ensure bunt is started before your application: 17 18 def application do 19 [applications: [:bunt]] 20 end 21 22 23 24 ## Usage 25 26 27 28 ### 256 colors 29 30 ![Colors](https://raw.github.com/rrrene/bunt/master/assets/colors.png) 31 32 `IO.ANSI` provides an interface to write text to the terminal in eight different colors like this: 33 34 ["Hello, ", :red, :bright, "world!"] 35 |> IO.ANSI.format 36 |> IO.puts 37 38 This will put the word "world!" in bright red. 39 40 To cause as little friction as possible, the interface of `Bunt.ANSI` is 100% adapted from `IO.ANSI`. 41 42 We can use `Bunt` in the same way: 43 44 ["Hello, ", :color202, :bright, "world!"] 45 |> Bunt.ANSI.format 46 |> IO.puts 47 48 which puts a bright orange-red `"world!"` on the screen. 49 50 `Bunt` also provides a shortcut so we can skip the `format` call. 51 52 ["Hello, ", :color202, :bright, "world!"] 53 |> Bunt.puts 54 55 and since nobody can remember that `:color202` is basically `:orangered`, you can use `:orangered` directly. 56 57 58 59 ### Named colors 60 61 The following colors were given names, so you can use them in style: 62 63 [:gold, "Look, it's really gold text!"] 64 |> Bunt.puts 65 66 Replace `:gold` with any of these values: 67 68 darkblue mediumblue darkgreen darkslategray darkcyan 69 deepskyblue springgreen aqua dimgray steelblue 70 darkred darkmagenta olive chartreuse aquamarine 71 greenyellow chocolate goldenrod lightgray beige 72 lightcyan fuchsia orangered hotpink darkorange 73 coral orange gold khaki moccasin 74 mistyrose lightyellow 75 76 You can see all supported colors by cloning the repo and running: 77 78 $ mix run script/colors.exs 79 80 ### User-defined color aliases 81 82 But since all these colors are hard to remember, you can alias them in your config.exs: 83 84 # I tend to start the names of my color aliases with an underscore 85 # but this is, naturally, not a must. 86 87 config :bunt, color_aliases: [_cupcake: :color205] 88 89 Then you can use these keys instead of the standard colors in your code: 90 91 [:_cupcake, "Hello World!"] 92 |> Bunt.puts 93 94 Use this to give your colors semantics. They get easier to change later that way. (A colleague of mine shouted "It's CSS for console applications!" when he saw this and although that is ... well, not true, I really like the sentiment! :+1:) 95 96 97 98 99 ## Contributing 100 101 1. [Fork it!](http://github.com/rrrene/bunt/fork) 102 2. Create your feature branch (`git checkout -b my-new-feature`) 103 3. Commit your changes (`git commit -am 'Add some feature'`) 104 4. Push to the branch (`git push origin my-new-feature`) 105 5. Create new Pull Request 106 107 108 109 ## Author 110 111 René Föhring (@rrrene) 112 113 114 115 ## License 116 117 Bunt is released under the MIT License. See the LICENSE file for further 118 details. 119 120 "Elixir" and the Elixir logo are copyright (c) 2012 Plataformatec. 121 122 Elixir source code is released under Apache 2 License. 123 124 Check NOTICE, ELIXIR-LICENSE and LICENSE files for more information.