from: github.com/remko/age-plugin-se

This commit is contained in:
2023-03-09 22:52:40 +08:00
parent 57fac2893c
commit 71927745a8
22 changed files with 2720 additions and 2 deletions

19
Sources/Stream.swift Normal file
View File

@@ -0,0 +1,19 @@
import Foundation
/// Abstraction of a line-based communication stream
protocol Stream {
func readLine() -> String?
func writeLine(_: String)
}
class StandardIOStream: Stream {
func readLine() -> String? {
return Swift.readLine(strippingNewline: true)
}
func writeLine(_ line: String) {
FileHandle.standardOutput.write(line.data(using: .utf8)!)
FileHandle.standardOutput.write(Data([0xa]))
fflush(stdout)
}
}