Created
June 8, 2019 22:56
-
-
Save cprovatas/d8d1729fe8621c35b46acf463cd091d3 to your computer and use it in GitHub Desktop.
Revisions
-
cprovatas created this gist
Jun 8, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ enum ASCIIColor: String { case black = "\u{001B}[0;30m" case red = "\u{001B}[0;31m" case green = "\u{001B}[0;32m" case yellow = "\u{001B}[0;33m" case blue = "\u{001B}[0;34m" case magenta = "\u{001B}[0;35m" case cyan = "\u{001B}[0;36m" case white = "\u{001B}[0;37m" case `default` = "\u{001B}[0;0m" } extension DefaultStringInterpolation { mutating func appendInterpolation<T: CustomStringConvertible>(_ value: T, color: ASCIIColor) { appendInterpolation("\(color.rawValue)\(value)\(ASCIIColor.default.rawValue)") } } // USAGE: // "\("only this string will be green!", color: .green)"