Move scripts

This commit is contained in:
Jáchym Toušek
2018-09-07 19:26:45 +02:00
parent cbd8626c6f
commit 985b54b3fa
10 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import Foundation
var standardError = FileHandle.standardError
extension FileHandle : TextOutputStream {
public func write(_ string: String) {
guard let data = string.data(using: .utf8) else { return }
self.write(data)
}
}
guard CommandLine.arguments.count > 1 else {
print("Usage: \(CommandLine.arguments[0]) file\nUse - to read from stdin", to: &standardError)
exit(EXIT_FAILURE)
}
let input: String
if CommandLine.arguments[1] == "-" {
input = String(decoding: FileHandle.standardInput.readDataToEndOfFile(), as: UTF8.self)
} else {
input = try String(contentsOf: URL(fileURLWithPath: CommandLine.arguments[1]))
}
let chars = Set(input.unicodeScalars)
let out = chars.sorted().lazy.map(Character.init)
print(String(out), terminator: "")