Skip to content

fuseraft/colorize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

colorize

A Kiwi package for colorizing terminal output using ANSI escape codes.


Installation

zest install fuseraft/colorize

Then in your script:

include ".zest/load.kiwi"

Usage

All named color and style functions print the colored string and return it, so they work both as standalone statements and inside expressions.

Quick example

include ".zest/load.kiwi"

for msg in ["error", "warning", "ok"] do
  colorize::red(msg)   when msg == "error"
  colorize::amber(msg) when msg == "warning"
  colorize::green(msg) when msg == "ok"
end

API

Foreground colors

colorize::red(msg)

Prints and returns msg in red.

colorize::red("something went wrong")

colorize::green(msg)

Prints and returns msg in green.

colorize::green("all systems go")

colorize::amber(msg)

Prints and returns msg in amber (yellow).

colorize::amber("proceed with caution")

colorize::blue(msg)

Prints and returns msg in blue.

colorize::blue("info: starting up")

colorize::magenta(msg)

Prints and returns msg in magenta.

colorize::magenta("debug output")

colorize::cyan(msg)

Prints and returns msg in cyan.

colorize::cyan("→ hint")

colorize::white(msg)

Prints and returns msg in white.

colorize::white("plain terminal white")

Text styles

colorize::bold(msg)

Prints and returns msg in bold.

colorize::bold("Section Header")

colorize::dim(msg)

Prints and returns msg in dim style.

colorize::dim("(optional)")

colorize::italic(msg)

Prints and returns msg in italic.

colorize::italic("see docs for details")

colorize::underline(msg)

Prints and returns msg with an underline.

colorize::underline("https://example.com")

Helpers

colorize::str(msg, code)

Returns the ANSI-escaped string without printing. Use this to build colored strings for embedding in larger output.

label = colorize::str("WARN", "33")
println "[${label}] disk usage above 90%"

colorize::paint(msg, code)

Low-level helper — same as str. Wraps msg with the given ANSI SGR code and appends a reset.

colorize::paint("custom", "35")   # magenta via raw code

colorize::reset(msg)

Appends a reset escape sequence after msg (no print). Useful when chaining raw ANSI codes manually.

line = "\u001b[1m" + colorize::reset("bold then normal")

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors