ansi - ANSI Color and Styling Utilities

Provides semantic style functions for terminal colors and text formatting.

Usage

ansi = require("ansi")

print("{{ansi.error('Error message')}}")
print("{{ansi.warning('Warning message')}}")
print("{{ansi.title('Section Title')}}")
print("{{ansi.code('some_function()')}}")

Semantic Styles

Convenience Functions

Building Custom Styles

Use combine() to build ANSI codes with multiple attributes including background colors:

ansi = require("ansi")

myStyle = ansi.combine(
  fg="magenta",
  bg="black",
  bold=true,
  underline=true
)

print("{{myStyle}}Custom styled text{{ansi.clear}}")

// Background color examples
alert = ansi.combine(fg="white", bg="red", bold=true)
highlight = ansi.combine(fg="black", bg="bright_yellow")

print("{{alert}}Critical alert{{ansi.clear}}")
print("{{highlight}}Important{{ansi.clear}}")

combine() Parameters

Color Names

Standard colors: black, red, green, yellow, blue, magenta, cyan, white, gray

Bright colors: bright_red, bright_green, bright_yellow, bright_blue, bright_magenta, bright_cyan, bright_white

Constants