Skip to content

Commit

Permalink
add executable target - "cli"
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiu committed Mar 15, 2020
1 parent 03fea13 commit 7fe4dff
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
Expand Down
2 changes: 2 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
]
)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
Expand All @@ -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"))

Expand Down
27 changes: 27 additions & 0 deletions Sources/cli/main.swift
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion Tests/ChalkTests/XCTestManifests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import XCTest

#if !os(macOS)
#if !canImport(ObjectiveC)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(ChalkTests.allTests),
Expand Down

0 comments on commit 7fe4dff

Please sign in to comment.