Colors.swift 0.1.1

Colors.swift 0.1.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jan 2016
SPMSupports SPM

Maintained by Justus Kandzi.



screenshot

Add some color to your terminal.

Inspired by colors.js.

Usage

Set foreground color:

print("Red".paint(.Red))

Set background color:

print("Red".paint(.OnRed))

Apply style:

print("Bold".style(.Bold))

Chain colors and styles:

print("Nice".paint(.Green).paint(.OnRed).style(.Bold))

print("Nice".paint(.Green, .OnRed))
print("Nice".paint(.Green, .OnRed, .Bold))

Available colors:

  • .Black
  • .Red
  • .Green
  • .Yellow
  • .Blue
  • .Magenta
  • .Cyan
  • .White
  • .Gray

Available background colors:

  • .OnBlack
  • .OnRed
  • .OnGreen
  • .OnYellow
  • .OnBlue
  • .OnMagenta
  • .OnCyan
  • .OnWhite
  • .OnGray

Available styles:

  • .Bold
  • .Dim
  • .Italic
  • .Underline
  • .Inverse
  • .Hidden
  • .Strikethrough

Installation

Swift Package Manager

To install with the Swift Package Manager, add the following in your Package.swift:

import PackageDescription

let package = Package(
    name: "MyProject",
    dependencies: [
        .Package(url: "https://github.com/jkandzi/Colors.swift", majorVersion: 0)
    ]
)

Manual

You can also copy the Colors.swift file into your Xcode project.

Author

Justus Kandzi, [email protected]

License

Colors.swift is available under the MIT license. See the LICENSE file for more info.