2
0
Fork 0
mirror of https://github.com/mas-cli/mas synced 2025-03-06 23:57:21 +00:00

Redo printing to stderr to avoid:

warning: extension declares a conformance of imported type 'FileHandle' to imported protocol 'TextOutputStream'; this will not behave correctly if the owners of 'Foundation' introduce this conformance in the future

Partial 

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2025-01-02 06:34:50 -05:00
parent 520d75d965
commit 3950606b99
No known key found for this signature in database

View file

@ -13,15 +13,21 @@ import Foundation
/// Terminal Control Sequence Indicator.
private let csi = "\u{001B}["
private var standardError = FileHandle.standardError
private var standardError = FileHandleTextOutputStream(FileHandle.standardError)
private struct FileHandleTextOutputStream: TextOutputStream {
private let fileHandle: FileHandle
init(_ fileHandle: FileHandle) {
self.fileHandle = fileHandle
}
extension FileHandle: TextOutputStream {
/// Appends the given string to the stream.
public func write(_ string: String) {
func write(_ string: String) {
guard let data = string.data(using: .utf8) else {
return
}
write(data)
fileHandle.write(data)
}
}