Ragex.CLI.Colors
(Ragex v0.10.0)
View Source
ANSI color helpers for CLI output.
Provides convenience functions for colored terminal output with support for NO_COLOR environment variable.
Examples
iex> Colors.success("Operation successful!")
"\e[32mOperation successful!\e[0m"
iex> Colors.error("Something went wrong")
"\e[31mSomething went wrong\e[0m"
Summary
Functions
Formats text with bold style.
Formats text with custom color and style.
Formats diff additions in green with + prefix.
Formats diff context in muted color.
Formats diff deletions in red with - prefix.
Returns true if colors are enabled.
Formats text in red for error messages.
Formats text as a section header with bold cyan.
Formats text in cyan for highlight messages.
Formats text in blue for info messages.
Formats text in dim gray for muted messages.
Formats text in green for success messages.
Formats text with underline.
Formats text in yellow for warning messages.
Types
Functions
Formats text with bold style.
Examples
IO.puts Colors.bold("Important")
Formats text with custom color and style.
Examples
IO.puts Colors.colorize("Custom", :magenta, :italic)
Formats diff additions in green with + prefix.
Examples
IO.puts Colors.diff_add("+ new line")
Formats diff context in muted color.
Examples
IO.puts Colors.diff_context(" context line")
Formats diff deletions in red with - prefix.
Examples
IO.puts Colors.diff_delete("- old line")
@spec enabled?() :: boolean()
Returns true if colors are enabled.
Colors are disabled when:
- NO_COLOR environment variable is set
- TERM environment variable is "dumb"
- Output is not a TTY
Formats text in red for error messages.
Examples
IO.puts Colors.error("Failed!")
Formats text as a section header with bold cyan.
Examples
IO.puts Colors.header("Step 1: Analysis")
Formats text in cyan for highlight messages.
Examples
IO.puts Colors.highlight("Important!")
Formats text in blue for info messages.
Examples
IO.puts Colors.info("Processing...")
Formats text in dim gray for muted messages.
Examples
IO.puts Colors.muted("(optional)")
Formats text in green for success messages.
Examples
IO.puts Colors.success("Done!")
Formats text with underline.
Examples
IO.puts Colors.underline("Link")
Formats text in yellow for warning messages.
Examples
IO.puts Colors.warning("Be careful!")