Skip to content

Commit a6b78c7

Browse files
kradalbyclaude
andcommitted
munin: drop Rainbow, inline ANSI for diff markers
Rainbow pulled a whole package just for `"[+]".green` and `"[-]".red` in prettyPrintAdded/Removed. Replace with three inline ANSI escape constants — prettyPrintAlbum already goes through `print(...)` so there was never a colour-aware abstraction to preserve. One fewer third-party dep, same terminal output. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9ccbe3c commit a6b78c7

4 files changed

Lines changed: 12 additions & 26 deletions

File tree

FUTURES.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,7 @@ cut upstream:
169169

170170
---
171171

172-
## 12. Consolidate Rainbow vs. ConsoleKit
173-
174-
Both `onevcat/Rainbow` and `vapor/console-kit` provide terminal colour
175-
APIs. Today Rainbow is used only in `Utils.swift` for `prettyPrintAdded`
176-
(green `+`) and `prettyPrintRemoved` (red `-`). Migrating those to
177-
ConsoleKit would let us drop Rainbow entirely, removing a dependency for
178-
trivial gain.
179-
180-
---
181-
182-
## 13. Static binary distribution
172+
## 12. Static binary distribution
183173

184174
`make build-static` uses `--static-swift-stdlib` which produces a ~73 MB
185175
binary with no Swift-runtime `.so` dependencies but still depends on the

Package.resolved

Lines changed: 1 addition & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ let package = Package(
4141
url: "https://github.com/kradalby/SwiftExif.git",
4242
revision: "eb7c5c4e034f0fc01c5a11b3c1d1ac3074f0acb1"),
4343
.package(url: "https://github.com/apple/swift-log.git", from: "1.12.0"),
44-
.package(url: "https://github.com/onevcat/Rainbow.git", from: "4.0.1"),
4544
// vapor/console-kit provides the progress/activity indicator UI that
4645
// replaced swift-tools-support-core's PercentProgressAnimation.
4746
.package(url: "https://github.com/vapor/console-kit.git", from: "4.16.0"),
@@ -72,7 +71,6 @@ let package = Package(
7271
.product(name: "SystemPackage", package: "swift-system"),
7372
.product(name: "Crypto", package: "swift-crypto"),
7473
"SwiftExif",
75-
"Rainbow",
7674
],
7775
exclude: ["Templates"]
7876
),

Sources/MuninKit/Utils.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
import Foundation
99
import Logging
10-
import Rainbow
10+
11+
// ANSI escapes for the `--diff` pretty-print markers. `prettyPrintAlbum`
12+
// writes through `print(...)` which already bypasses any colour-aware
13+
// terminal abstraction, so keeping two local constants is simpler than
14+
// pulling in a colour-helper dependency.
15+
private let ansiGreen = "\u{001B}[32m"
16+
private let ansiRed = "\u{001B}[31m"
17+
private let ansiReset = "\u{001B}[0m"
1118

1219
func readAndDecodeJsonFile<T>(_ type: T.Type, atPath: String) -> T?
1320
where T: Decodable {
@@ -136,11 +143,11 @@ func prettyPrintAlbum(_ album: Album, marker: String = "") {
136143
}
137144

138145
func prettyPrintAdded(_ album: Album) {
139-
prettyPrintAlbum(album, marker: "[+]".green)
146+
prettyPrintAlbum(album, marker: "\(ansiGreen)[+]\(ansiReset)")
140147
}
141148

142149
func prettyPrintRemoved(_ album: Album) {
143-
prettyPrintAlbumCompact(album, marker: "[-]".red)
150+
prettyPrintAlbumCompact(album, marker: "\(ansiRed)[-]\(ansiReset)")
144151
}
145152

146153
func prettyPrintAlbumCompact(_ album: Album, marker: String) {

0 commit comments

Comments
 (0)