Module: SwarmCLI::V3::ANSIColors

Defined in:
lib/swarm_cli/v3/ansi_colors.rb

Overview

Minimal ANSI escape code helpers for terminal styling.

Avoids external dependencies (like Pastel) to keep the V3 CLI lightweight. Each method wraps text in an ANSI escape sequence and appends the reset code.

Examples:

ANSIColors.bold("hello")  # => "\e[1mhello\e[0m"
ANSIColors.red("error")   # => "\e[31merror\e[0m"

Constant Summary collapse

RESET =
"\e[0m"
BOLD =
"\e[1m"
DIM =
"\e[2m"
ITALIC =
"\e[3m"
REVERSE =
"\e[7m"
GREEN =
"\e[32m"
CYAN =
"\e[36m"
YELLOW =
"\e[33m"
RED =
"\e[31m"
BLUE =
"\e[34m"
MAGENTA =
"\e[35m"

Class Method Summary collapse

Class Method Details

.blue(text) ⇒ String

Returns blue-colored text.

Parameters:

  • text (String)

    text to wrap

Returns:

  • (String)

    blue-colored text



62
# File 'lib/swarm_cli/v3/ansi_colors.rb', line 62

def blue(text)    = "#{BLUE}#{text}#{RESET}"

.bold(text) ⇒ String

Returns bold-styled text.

Parameters:

  • text (String)

    text to wrap

Returns:

  • (String)

    bold-styled text



30
# File 'lib/swarm_cli/v3/ansi_colors.rb', line 30

def bold(text)    = "#{BOLD}#{text}#{RESET}"

.cyan(text) ⇒ String

Returns cyan-colored text.

Parameters:

  • text (String)

    text to wrap

Returns:

  • (String)

    cyan-colored text



50
# File 'lib/swarm_cli/v3/ansi_colors.rb', line 50

def cyan(text)    = "#{CYAN}#{text}#{RESET}"

.dim(text) ⇒ String

Returns dim-styled text.

Parameters:

  • text (String)

    text to wrap

Returns:

  • (String)

    dim-styled text



34
# File 'lib/swarm_cli/v3/ansi_colors.rb', line 34

def dim(text)     = "#{DIM}#{text}#{RESET}"

.green(text) ⇒ String

Returns green-colored text.

Parameters:

  • text (String)

    text to wrap

Returns:

  • (String)

    green-colored text



46
# File 'lib/swarm_cli/v3/ansi_colors.rb', line 46

def green(text)   = "#{GREEN}#{text}#{RESET}"

.italic(text) ⇒ String

Returns italic-styled text.

Parameters:

  • text (String)

    text to wrap

Returns:

  • (String)

    italic-styled text



38
# File 'lib/swarm_cli/v3/ansi_colors.rb', line 38

def italic(text)  = "#{ITALIC}#{text}#{RESET}"

.magenta(text) ⇒ String

Returns magenta-colored text.

Parameters:

  • text (String)

    text to wrap

Returns:

  • (String)

    magenta-colored text



66
# File 'lib/swarm_cli/v3/ansi_colors.rb', line 66

def magenta(text) = "#{MAGENTA}#{text}#{RESET}"

.red(text) ⇒ String

Returns red-colored text.

Parameters:

  • text (String)

    text to wrap

Returns:

  • (String)

    red-colored text



58
# File 'lib/swarm_cli/v3/ansi_colors.rb', line 58

def red(text)     = "#{RED}#{text}#{RESET}"

.reverse(text) ⇒ String

Returns reverse-video styled text.

Parameters:

  • text (String)

    text to wrap

Returns:

  • (String)

    reverse-video styled text



42
# File 'lib/swarm_cli/v3/ansi_colors.rb', line 42

def reverse(text) = "#{REVERSE}#{text}#{RESET}"

.yellow(text) ⇒ String

Returns yellow-colored text.

Parameters:

  • text (String)

    text to wrap

Returns:

  • (String)

    yellow-colored text



54
# File 'lib/swarm_cli/v3/ansi_colors.rb', line 54

def yellow(text)  = "#{YELLOW}#{text}#{RESET}"