Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrene committed Nov 9, 2015
1 parent d5ea613 commit aa972eb
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 4 deletions.
90 changes: 87 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Bunt

Enables 256 color ANSI coloring in the terminal.
Enables 256 color ANSI coloring in the terminal and gives you the ability to alias colors to more semantic and application-specfic names.

![Colors](https://raw.github.com/rrrene/bunt/master/assets/colors.png)


## Installation
Expand All @@ -24,14 +25,97 @@ If [available in Hex](https://hex.pm/docs/publish), the package can be installed

## Usage



### 256 colors

IO.ANSI provides an interface to write text to the terminal in eight different colors like this:

["Hello, ", :red, :bright, "world!"]
|> IO.ANSI.format
|> IO.puts

This will put the word "world!" in bright red.

To cause as little friction as possible, the interface of `Bunt.ANSI` is 100% adapted from `IO.ANSI`.

We can use `Bunt` in the same way:

["Hello, ", :color202, :bright, "world!"]
|> Bunt.ANSI.format
|> Bunt.puts

which puts a bright orange-red `"world!"` on the screen.

`Bunt` also provides a shortcut so we can skip the `format` call.

["Hello, ", :color202, :bright, "world!"]
|> Bunt.puts

and since nobody can remember that `:color202` is basically `:orangered`, you can use `:orangered` directly.



### Named colors

The following colors were given names, so you can use them in style:

[:gold, "Look, it's really gold text!"]
|> Bunt.puts

Replace `:gold` with any of these values:

darkblue mediumblue darkgreen darkslategray darkcyan
deepskyblue springgreen aqua dimgray steelblue
darkred darkmagenta olive chartreuse aquamarine
greenyellow chocolate goldenrod lightgray beige
lightcyan fuchsia orangered hotpink darkorange
coral orange gold khaki moccasin
mistyrose lightyellow

You can see all supported colors by cloning the repo and running:

$ mix run script/colors.exs

TODO: write actual usage instructions
### User-defined color aliases

But since all these colors are hard to remember, you can alias them in your config.exs:

# I tend to start the names of my color aliases with an underscore
# but this is, naturally, not a must.

config :bunt, color_aliases: [_cupcake: :color205]

Then you can use these keys instead of the standard colors in your code:

[:_cupcake, "Hello World!"]
|> Bunt.puts

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)




## Contributing

1. [Fork it!](http://github.com/rrrene/bunt/fork)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request



## Author

René Föhring (@rrrene)



## License

# License
Bunt is released under the MIT License. See the LICENSE file for further
details.

"Elixir" and the Elixir logo are copyright (c) 2012 Plataformatec.

Expand Down
Binary file added assets/colors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion script/colors.exs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Bunt.puts
Bunt.puts [:_code, " [:gold, \"Look, it's really gold text!\"] |> Bunt.puts"]
Bunt.puts [:_code, " ", [:gold, "Look, it's really gold text!"]]
Bunt.puts
Bunt.puts "Replace `hotpink` with any of these values:"
Bunt.puts "Replace `:gold` with any of these values:"
Bunt.puts


Expand Down

0 comments on commit aa972eb

Please sign in to comment.