-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmain.swift
More file actions
executable file
·134 lines (120 loc) · 7.27 KB
/
main.swift
File metadata and controls
executable file
·134 lines (120 loc) · 7.27 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//#!cat ../Source/ColorizeSwift.swift main.swift | swift -
//
// main.swift
// Colorize
//
// Created by Michał Tynior on 07/01/16.
// Copyright © 2016 Michał Tynior. All rights reserved.
//
func printStyles() {
print("Normal")
print("Bold".bold())
print("Dim".dim())
print("Italic".italic())
print("Underline".underline())
print("Blink".blink())
print("Reverse".reverse())
print("Hidden".hidden())
print("strikethrough".strikethrough())
print("Red".red())
print("On yellow".onYellow())
print("256 foreground".foregroundColor(.orange1))
print("226 background".backgroundColor(.orange1))
print("Awful combination".colorize(.yellow, background: .red))
let nested = "with a blue, underline substring".blue().underline()
print("A bold, green line \(nested) that becomes bold and green again".green().bold())
}
func printF1() {
let car1 = TerminalColor.green.foregroundStyleCode().open
let car2 = TerminalColor.red.foregroundStyleCode().open
let car3 = TerminalColor.mediumPurple.foregroundStyleCode().open
let car4 = TerminalColor.yellow1.foregroundStyleCode().open
print("\n\n")
print("██ ██ ██ ██ ██ ██ ██ ██ ██ ██".white())
print(" ██ ██ ██ ██ ██ ██ ██ ██ ██ ".white())
print("\n\n")
print(car1 + " ▄▄ " )
print(car1 + " ██▬██▬██ " + car2 + " ▄▄ ")
print(car1 + " ████ " + car2 + " ██▬██▬██ ")
print(car1 + " ▄██ ██▄ " + car2 + " ████ ")
print(car1 + " ▄▄▄▀█ █▀▄▄▄ " + car2 + " ▄██ ██▄ ")
print(car1 + " ███▀████▀███ " + car2 + " ▄▄▄▀█ █▀▄▄▄ ")
print(car1 + " ▀ ▀ " + car2 + " ███▀████▀███ ")
print(car1 + " " + car2 + " ▀ ▀ ")
print(car1 + "\n\n")
print(car3 + " ▄▄ " )
print(car3 + " ██▬██▬██ " + car4 + " ▄▄ ")
print(car3 + " ████ " + car4 + " ██▬██▬██ ")
print(car3 + " ▄██ ██▄ " + car4 + " ████ ")
print(car3 + " ▄▄▄▀█ █▀▄▄▄ " + car4 + " ▄██ ██▄ ")
print(car3 + " ███▀████▀███ " + car4 + " ▄▄▄▀█ █▀▄▄▄ ")
print(car3 + " ▀ ▀ " + car4 + " ███▀████▀███ ")
print(car3 + " " + car4 + " ▀ ▀ ")
print("\n\n")
}
func printPacman() {
// inspired by https://github.com/jaykru/colorscripts
let pacmanColor = TerminalColor.yellow.foregroundStyleCode().open
let blinkyColor = TerminalColor.red.foregroundStyleCode().open
let pinkyColor = TerminalColor.pink1.foregroundStyleCode().open
let inkyColor = TerminalColor.blue.foregroundStyleCode().open
let clydeColor = TerminalColor.gold1.foregroundStyleCode().open
let white = TerminalColor.white.foregroundStyleCode().open
print("\n\n")
print("\(pacmanColor) ▄███████▄ \(blinkyColor) ▄██████▄ \(pinkyColor) ▄██████▄ \(inkyColor) ▄██████▄ \(clydeColor) ▄██████▄ ")
print("\(pacmanColor)▄█████████▀▀ \(blinkyColor)▄\(white)█▀█\(blinkyColor)██\(white)█▀█\(blinkyColor)██▄ \(pinkyColor)▄\(white)█▀█\(pinkyColor)██\(white)█▀█\(pinkyColor)██▄ \(inkyColor)▄\(white)█▀█\(inkyColor)██\(white)█▀█\(inkyColor)██▄ \(clydeColor)▄\(white)█▀█\(clydeColor)██\(white)█▀█\(clydeColor)██▄")
print("\(pacmanColor)███████▀ \(blinkyColor)█\(white)▄▄█\(blinkyColor)██\(white)▄▄█\(blinkyColor)███ \(pinkyColor)█\(white)▄▄█\(pinkyColor)██\(white)▄▄█\(pinkyColor)███ \(inkyColor)█\(white)▄▄█\(inkyColor)██\(white)▄▄█\(inkyColor)███ \(clydeColor)█\(white)▄▄█\(clydeColor)██\(white)▄▄█\(clydeColor)███")
print("\(pacmanColor)███████▄ \(blinkyColor)████████████ \(pinkyColor)████████████ \(inkyColor)████████████ \(clydeColor)████████████")
print("\(pacmanColor)▀█████████▄▄ \(blinkyColor)██▀██▀▀██▀██ \(pinkyColor)██▀██▀▀██▀██ \(inkyColor)██▀██▀▀██▀██ \(clydeColor)██▀██▀▀██▀██")
print("\(pacmanColor) ▀███████▀ \(blinkyColor)▀ ▀ ▀ ▀ \(pinkyColor)▀ ▀ ▀ ▀ \(inkyColor)▀ ▀ ▀ ▀ \(clydeColor)▀ ▀ ▀ ▀")
print("\n\n")
}
func printMario() {
let red = TerminalColor.red.foregroundStyleCode().open
let brown = TerminalColor.darkRed.foregroundStyleCode().open
let skin = TerminalColor.sandyBrown.foregroundStyleCode().open
let eye = TerminalColor.black.foregroundStyleCode().open
let trousers = TerminalColor.deepSkyBlue4_2.foregroundStyleCode().open
let button = TerminalColor.yellow.foregroundStyleCode().open
print("\n\n")
print("\(red) █████ ")
print("\(red) █████████ ")
print("\(brown) ███\(skin)██\(eye)█\(skin)█ ")
print("\(brown) █\(skin)█\(brown)█\(skin)███\(eye)█\(skin)███ ")
print("\(brown) █\(skin)█\(brown)██\(skin)████\(brown)█\(skin)██")
print("\(brown) ██\(skin)████\(brown)████ ")
print("\(skin) ██████ ")
print("\(red) ██\(trousers)█\(red)███ ")
print("\(red) ███\(trousers)█\(red)██\(trousers)█\(red)███ ")
print("\(red) ████\(trousers)████\(red)████")
print("\(skin) ██\(red)█\(trousers)█\(button)█\(trousers)██\(button)█\(trousers)█\(red)█\(skin)██")
print("\(skin) ███\(trousers)██████\(skin)███")
print("\(skin) ██\(trousers)████████\(skin)██")
print("\(trousers) ███ ███ ")
print("\(brown) ███ ███ ")
print("\(brown) ████ ████")
print("\n\n")
}
func printInfo() {
print("Available examples:\n")
print(" styles Print available styles.")
print(" f1 Print F1 cars.")
print(" pacman Print Pacman")
print(" mario Print Mario")
print("\n")
}
if CommandLine.arguments.count != 2 {
printInfo()
}
else {
let argument = CommandLine.arguments[1]
switch (argument.lowercased()) {
case "styles": printStyles()
case "f1": printF1()
case "pacman": printPacman()
case "mario": printMario()
default:
print("Unrecognized command `\(argument)`.")
printInfo()
}
}