diff --git a/Package.resolved b/Package.resolved index 9240835..87953c9 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/luoxiu/Rainbow", "state": { "branch": null, - "revision": "177c6ebae4389c0363ea1bf62a7257151d53acbc", - "version": "0.0.4" + "revision": "438720f94da08582aff2abc4712de1c23f464d45", + "version": "0.0.5" } } ] diff --git a/Package.swift b/Package.swift index fdaa115..d8f307d 100644 --- a/Package.swift +++ b/Package.swift @@ -6,12 +6,14 @@ let package = Package( name: "Chalk", products: [ .library(name: "Chalk", targets: ["Chalk"]), + .executable(name: "cli", targets: ["cli"]), ], dependencies: [ .package(url: "https://github.com/luoxiu/Rainbow", from: "0.0.1"), ], targets: [ .target(name: "Chalk", dependencies: ["Rainbow"]), + .target(name: "cli", dependencies: ["Chalk"]), .testTarget(name: "ChalkTests", dependencies: ["Chalk"]), ] ) diff --git a/README.md b/README.md index 7e34ad1..5b85c1b 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ - Expressive API - 256/TrueColor support -- Nestable +- Ability to nest styles - Auto downgrading to terminal color support level - No extensions on `String` - Built-in 100+ handpicked colors @@ -35,7 +35,7 @@ Chalk's API is very similar to [chalk](https://github.com/chalk/chalk) -- one of ```swift -print(chalk.cyan.on("cyan")) // `ck` is an alias to `chalk` +print(Chalk.cyan.on("cyan")) // `ck` is an alias to `chalk` // chainable print(ck.red.bgMagenta.bold.underline.on("red bgMagenta bild underline")) @@ -49,7 +49,7 @@ print(ck.fg(.coral).bg(.lightGreen).bold.on("hi")) // rgb & hsl & hsv & hex support print(ck.fg(.rgb(0, 92, 197)).bg(.hex(0xf6f8fa)).underline.on("meow")) -// nestable +// nest print(ck.bgYellow.on("begin" + ck.red.bold.on("important") + "end")) print(ck.bgYellow.on("begin", ck.red.bold.on("important"), "end")) diff --git a/Sources/cli/main.swift b/Sources/cli/main.swift new file mode 100644 index 0000000..3fe2b46 --- /dev/null +++ b/Sources/cli/main.swift @@ -0,0 +1,27 @@ +// +// File.swift +// +// +// Created by jinxiangqiu on 15/3/2020. +// + +import Foundation +import Chalk + +extension String { + + var success: String { + return ck.fg(.springGreen).on(self).description + } + + var failure: String { + return ck.fg(.red).on(self).description + } +} + +func say(_ msg: String) { + print(ck.cyan.bold.on("Q:"), msg) +} + +say("success".success) +say("failure".failure) diff --git a/Tests/ChalkTests/XCTestManifests.swift b/Tests/ChalkTests/XCTestManifests.swift index 517dfb7..0bd8391 100644 --- a/Tests/ChalkTests/XCTestManifests.swift +++ b/Tests/ChalkTests/XCTestManifests.swift @@ -1,6 +1,6 @@ import XCTest -#if !os(macOS) +#if !canImport(ObjectiveC) public func allTests() -> [XCTestCaseEntry] { return [ testCase(ChalkTests.allTests),