Colorful

This module is a wrapper for IO.ANSI module.

iex> use Colorful

iex> Colorful.string("hello", "red underline")
"hello"

iex> Colorful.string("hello", ["red", "underline"])
"hello"

iex> Colorful.string("hello", [:red, :underline])
"hello"

iex> Colorful.puts("hello", "red")
hello   # colored

iex> Colorful.inspect(:hello, "red")
:hello  # colored
:hello  # return value, an atom

Followings are valid decorators.

Summary

inspect(text, decorators \\ "reset")

This writes colored string to stdout. The string is made of first argument according to Inspect protocol

inspect(device, text, decorators)

Inspects decorated text to specified device

puts(text, decorators \\ "reset")

This outputs colored string to stdout as same as IO.puts. The return value is always :ok

puts(device, text, decorators)

Outputs decorated text to specified device, similar to IO.puts/2

string(text, decorators \\ "reset")

This function makes given string decorated

Types

decorators :: String.t | [String.t | atom]

Macros

inspect(text, decorators \\ "reset")

This writes colored string to stdout. The string is made of first argument according to Inspect protocol.

This returns given first argument as it is.

inspect(device, text, decorators)

Inspects decorated text to specified device.

puts(text, decorators \\ "reset")

This outputs colored string to stdout as same as IO.puts. The return value is always :ok.

puts(device, text, decorators)

Outputs decorated text to specified device, similar to IO.puts/2

string(text, decorators \\ "reset")

This function makes given string decorated.

The decoration is specified in the second argument. It is a string, or a list which members are string or atom.