Skip to content

SomeKindOfCode/SwiftANSI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftANSI

Colorize your terminal output with ANSI Colors

Swift 3.0 Twitter Follow

Simply use it on any String.

public func textColor(_ color: ANSIColor) -> String {}
public func backgroundColor(_ color: ANSIColor) -> String {}
public func style(_ style: ANSIStyle) -> String {}

Example:

"This " +
"line ".textColor(.Yellow) +
"is " +
"mixed".backgroundColor(.Blue)

chaining possible

"Lorem Ipsum".style(.Bold)
  .textColor(.Red)
  .backgroundColor(.White)

Colors

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

Styles

  • Bold
  • Italic
  • Underline
  • Inverse
  • Blink
  • Strikethrough

You can take a look at the Sources/main.swift to. This file is no included in the compiled package!

Install

Add a dependency to your Package.swift

import PackageDescription

let package = Package(
    name: "YourPackage",
    dependencies: [
        .Package(url: "[email protected]:somekindofcode/SwiftANSI.git", majorVersion: 1)
    ]
)