Colorful

This module is a wrapper for IO.ANSI module.

iex> Colorful.string("hello", "red underline")
"\e[0m\e[31m\e[4mhello\e[0m"

iex> Colorful.string("hello", ["red", "underline"])
"\e[0m\e[31m\e[4mhello\e[0m"

iex> Colorful.string("hello", [:red, :underline])
"\e[0m\e[31m\e[4mhello\e[0m"

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(term, decorators \\ nil)

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

inspect(device, term, decorators)

Inspects decorated text to specified device

puts(text, decorators \\ nil)

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 \\ nil)

This function makes given string decorated

Types

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

Functions

inspect(term, decorators \\ nil)

Specs:

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, term, decorators)

Specs:

Inspects decorated text to specified device.

puts(text, decorators \\ nil)

Specs:

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

puts(device, text, decorators)

Specs:

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

string(text, decorators \\ nil)

Specs:

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.