Skip to content

A swift library for adding colors and effects to the terminal

License

Notifications You must be signed in to change notification settings

DariuszGulbicki/colorizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project banner

Colorizer

A swift library for adding colors and effects to the terminal.

Installation

Swift Package Manager

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")

Usage

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:

Printed examples

Contributing

Contributions are welcome. Please open an issue or submit a pull request.

License

Colorizer is released under the MIT license. See LICENSE for details.

About

A swift library for adding colors and effects to the terminal

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages