A swift library for adding colors and effects to the terminal.
You can use The Swift Package Manager to install Colorizer
by adding the proper description to your Package.swift
file:
.package(url: "https://github.com/DariuszGulbicki/colorizer.git", from: "1.0.0")
Import the library:
import Colorizer
Colorize a string:
// Add single effect
Colorizer.colorize("Hello, world!", .red)
// Add multiple effects
Colorizer.colorize("Hello, world!", .bold, .underline)
Format a string:
// Create colorizer object
var colorizer = Colorizer()
// Format a string with colorizer
colorizer.format("&(bold)&(underline)&(yellow)Hello, &(green)world!&(reset)")
Rainbowify a string:
// Rainbow with standard colors
Colorizer.rainbow("This is just a test!")
// Custom rainbow
Colorizer.rainbow("Hello, World!", .brightRed, .brightGreen, .brightWhite)
// Custom rainbow with multiple effects
Colorizer.rainbow("Hello, World!", [[.bold, .underline, .red], [.bold, .underline, .green], [.bold, .underline, .white]])
If you print these examples to the terminal, you should see something like this:
Contributions are welcome. Please open an issue or submit a pull request.
Colorizer is released under the MIT license. See LICENSE for details.