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 #696 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
parent
520d75d965
commit
3950606b99
1 changed files with 10 additions and 4 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue