Skip to content

Commit

Permalink
some api should be public
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiu committed Jun 22, 2020
1 parent d761fdb commit 0a03a83
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 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": "438720f94da08582aff2abc4712de1c23f464d45",
"version": "0.0.5"
"revision": "9bc8fa136c8cec2f4a5c8ad1e8d37753e05db9d5",
"version": "0.1.0"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let package = Package(
.executable(name: "chalk-app", targets: ["chalk-app"]),
],
dependencies: [
.package(url: "https://github.com/luoxiu/Rainbow", from: "0.0.1"),
.package(url: "https://github.com/luoxiu/Rainbow", from: "0.1.0"),
],
targets: [
.target(name: "Chalk", dependencies: ["Rainbow"]),
Expand Down
28 changes: 24 additions & 4 deletions Sources/Chalk/Style.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@ public struct Style {
public var bgColor: TerminalColor?

public var modifiers: Set<Modifier>?

public init(fgColor: TerminalColor? = nil,
bgColor: TerminalColor? = nil,
modifiers: Set<Modifier>? = nil) {
self.fgColor = fgColor
self.bgColor = bgColor
self.modifiers = modifiers
}
}

extension Style {

private func on(_ other: Style) -> Style {
public func on(_ other: Style) -> Style {
var style = self
style.fgColor = other.fgColor ?? style.fgColor
style.bgColor = other.bgColor ?? style.bgColor
Expand All @@ -48,7 +56,7 @@ extension Style {

extension Style {

private func modify(_ modifier: Modifier) -> Style {
public func modify(_ modifier: Modifier) -> Style {
var style = self
if style.modifiers == nil {
style.modifiers = [modifier]
Expand Down Expand Up @@ -109,13 +117,13 @@ extension Style {

extension Style {

private func fg(ansi16: ANSI16Color) -> Style {
public func fg(ansi16: ANSI16Color) -> Style {
var style = self
style.fgColor = ansi16
return style
}

private func bg(ansi16: ANSI16Color) -> Style {
public func bg(ansi16: ANSI16Color) -> Style {
var style = self
style.bgColor = ansi16
return style
Expand Down Expand Up @@ -271,4 +279,16 @@ extension Style {
style.bgColor = color
return style
}

public func fg(_ color: ANSI16Color) -> Style {
var style = self
style.fgColor = color
return style
}

public func bg(_ color: ANSI16Color) -> Style {
var style = self
style.bgColor = color
return style
}
}
1 change: 1 addition & 0 deletions Sources/chalk-app/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ print(
$0 + $1
}
)

0 comments on commit 0a03a83

Please sign in to comment.