-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.swift
54 lines (48 loc) · 1.22 KB
/
main.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// main.swift
// unicode-scripterizer
//
// Created by ArgentWolf on 2019-09-21
//
// This is free and unencumbered software released into the public domain.
// See COPYING.md for more information.
//
// vim:set noet fo=tcqr:
//
import Foundation
var script: Script = ScriptSelection.script
if CommandLine.arguments.contains("-S") {
script = ScriptSelection.fancyScript
}
if CommandLine.arguments.contains("-b") {
script = ScriptSelection.blackletterLight
}
if CommandLine.arguments.contains("-B") {
script = ScriptSelection.blackletterBold
}
if CommandLine.arguments.contains("-r") {
script = ScriptSelection.runes
}
if CommandLine.arguments.contains("-R") {
script = ScriptSelection.runes
(script as! RuneScript).spacingMode = .spaced
}
if CommandLine.arguments.contains("-i") {
script = ScriptSelection.icelandicRunes
}
if CommandLine.arguments.contains("-c") {
script = ScriptSelection.smallCaps
}
if CommandLine.arguments.contains("-d") {
script = ScriptSelection.doublestruck
}
let fh = FileHandle.standardInput
while (true) {
let data = fh.availableData
if data.count == 0 { // returns empty on EOF
break
}
let str = String(data: data, encoding: .utf8)!
print(script.convert(str), terminator: "")
fflush(stdout)
}