I am writing a BASIC Interpreter for the Command Line in Swift 2, and I cannot find a way to implement the simple command, CLS (clear all text from the Terminal.) Should I s
This code makes a synchronous call to the built-in clear command. This won't cause problem with readLine() since it prints the escape sequence returned by clear using Swift's print() function
var cls = Process()
var out = Pipe()
cls.launchPath = "/usr/bin/clear"
cls.standardOutput = out
cls.launch()
cls.waitUntilExit()
print (String(data: out.fileHandleForReading.readDataToEndOfFile(), encoding: String.Encoding.utf8) ?? "")