-
Notifications
You must be signed in to change notification settings - Fork 119
/
style.go
227 lines (219 loc) · 12.2 KB
/
style.go
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
package table
import "github.com/jedib0t/go-pretty/text"
// Style declares how to render the Table.
type Style struct {
BoxBottomLeft string
BoxBottomRight string
BoxBottomSeparator string
BoxLeft string
BoxLeftSeparator string
BoxMiddleHorizontal string
BoxMiddleSeparator string
BoxMiddleVertical string
BoxPaddingLeft string
BoxPaddingRight string
BoxRight string
BoxRightSeparator string
BoxTopLeft string
BoxTopRight string
BoxTopSeparator string
BoxUnfinishedRow string
FormatHeader text.Format
FormatFooter text.Format
FormatRows text.Format
Name string
}
var (
// StyleDefault renders a Table like below:
// +-----+------------+-----------+--------+-----------------------------+
// | # | FIRST NAME | LAST NAME | SALARY | |
// +-----+------------+-----------+--------+-----------------------------+
// | 1 | Arya | Stark | 3000 | |
// | 20 | Jon | Snow | 2000 | You know nothing, Jon Snow! |
// | 300 | Tyrion | Lannister | 5000 | |
// +-----+------------+-----------+--------+-----------------------------+
// | | | TOTAL | 10000 | |
// +-----+------------+-----------+--------+-----------------------------+
StyleDefault = Style{
BoxBottomLeft: "+",
BoxBottomRight: "+",
BoxBottomSeparator: "+",
BoxLeft: "|",
BoxLeftSeparator: "+",
BoxMiddleHorizontal: "-",
BoxMiddleSeparator: "+",
BoxMiddleVertical: "|",
BoxPaddingLeft: " ",
BoxPaddingRight: " ",
BoxRight: "|",
BoxRightSeparator: "+",
BoxTopLeft: "+",
BoxTopRight: "+",
BoxTopSeparator: "+",
BoxUnfinishedRow: " ~",
FormatFooter: text.FormatUpper,
FormatHeader: text.FormatUpper,
FormatRows: text.FormatDefault,
Name: "StyleDefault",
}
// StyleBold renders a Table like below:
// ┏━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
// ┃ # ┃ FIRST NAME ┃ LAST NAME ┃ SALARY ┃ ┃
// ┣━━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
// ┃ 1 ┃ Arya ┃ Stark ┃ 3000 ┃ ┃
// ┃ 20 ┃ Jon ┃ Snow ┃ 2000 ┃ You know nothing, Jon Snow! ┃
// ┃ 300 ┃ Tyrion ┃ Lannister ┃ 5000 ┃ ┃
// ┣━━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
// ┃ ┃ ┃ TOTAL ┃ 10000 ┃ ┃
// ┗━━━━━┻━━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
StyleBold = Style{
BoxBottomLeft: text.BoxBottomLeftBold,
BoxBottomRight: text.BoxBottomRightBold,
BoxBottomSeparator: text.BoxBottomSeparatorBold,
BoxLeft: text.BoxLeftBold,
BoxLeftSeparator: text.BoxLeftSeparatorBold,
BoxMiddleHorizontal: text.BoxHorizontalBold,
BoxMiddleSeparator: text.BoxSeparatorBold,
BoxMiddleVertical: text.BoxVerticalBold,
BoxPaddingLeft: " ",
BoxPaddingRight: " ",
BoxRight: text.BoxRightBold,
BoxRightSeparator: text.BoxRightSeparatorBold,
BoxTopLeft: text.BoxTopLeftBold,
BoxTopRight: text.BoxTopRightBold,
BoxTopSeparator: text.BoxTopSeparatorBold,
BoxUnfinishedRow: " " + text.BoxUnfinishedLine,
FormatFooter: text.FormatUpper,
FormatHeader: text.FormatUpper,
FormatRows: text.FormatDefault,
Name: "StyleBold",
}
// StyleDouble renders a Table like below:
// ╔═════╦════════════╦═══════════╦════════╦═════════════════════════════╗
// ║ # ║ FIRST NAME ║ LAST NAME ║ SALARY ║ ║
// ╠═════╬════════════╬═══════════╬════════╬═════════════════════════════╣
// ║ 1 ║ Arya ║ Stark ║ 3000 ║ ║
// ║ 20 ║ Jon ║ Snow ║ 2000 ║ You know nothing, Jon Snow! ║
// ║ 300 ║ Tyrion ║ Lannister ║ 5000 ║ ║
// ╠═════╬════════════╬═══════════╬════════╬═════════════════════════════╣
// ║ ║ ║ TOTAL ║ 10000 ║ ║
// ╚═════╩════════════╩═══════════╩════════╩═════════════════════════════╝
StyleDouble = Style{
BoxBottomLeft: text.BoxBottomLeftDouble,
BoxBottomRight: text.BoxBottomRightDouble,
BoxBottomSeparator: text.BoxBottomSeparatorDouble,
BoxLeft: text.BoxLeftDouble,
BoxLeftSeparator: text.BoxLeftSeparatorDouble,
BoxMiddleHorizontal: text.BoxHorizontalDouble,
BoxMiddleSeparator: text.BoxSeparatorDouble,
BoxMiddleVertical: text.BoxVerticalDouble,
BoxPaddingLeft: " ",
BoxPaddingRight: " ",
BoxRight: text.BoxRightDouble,
BoxRightSeparator: text.BoxRightSeparatorDouble,
BoxTopLeft: text.BoxTopLeftDouble,
BoxTopRight: text.BoxTopRightDouble,
BoxTopSeparator: text.BoxTopSeparatorDouble,
BoxUnfinishedRow: " " + text.BoxUnfinishedLine,
FormatFooter: text.FormatUpper,
FormatHeader: text.FormatUpper,
FormatRows: text.FormatDefault,
Name: "StyleDouble",
}
// StyleLight renders a Table like below:
// ┌─────┬────────────┬───────────┬────────┬─────────────────────────────┐
// │ # │ FIRST NAME │ LAST NAME │ SALARY │ │
// ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤
// │ 1 │ Arya │ Stark │ 3000 │ │
// │ 20 │ Jon │ Snow │ 2000 │ You know nothing, Jon Snow! │
// │ 300 │ Tyrion │ Lannister │ 5000 │ │
// ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤
// │ │ │ TOTAL │ 10000 │ │
// └─────┴────────────┴───────────┴────────┴─────────────────────────────┘
StyleLight = Style{
BoxBottomLeft: text.BoxBottomLeft,
BoxBottomRight: text.BoxBottomRight,
BoxBottomSeparator: text.BoxBottomSeparator,
BoxLeft: text.BoxLeft,
BoxLeftSeparator: text.BoxLeftSeparator,
BoxMiddleHorizontal: text.BoxHorizontal,
BoxMiddleSeparator: text.BoxSeparator,
BoxMiddleVertical: text.BoxVertical,
BoxPaddingLeft: " ",
BoxPaddingRight: " ",
BoxRight: text.BoxRight,
BoxRightSeparator: text.BoxRightSeparator,
BoxTopLeft: text.BoxTopLeft,
BoxTopRight: text.BoxTopRight,
BoxTopSeparator: text.BoxTopSeparator,
BoxUnfinishedRow: " " + text.BoxUnfinishedLine,
FormatFooter: text.FormatUpper,
FormatHeader: text.FormatUpper,
FormatRows: text.FormatDefault,
Name: "StyleLight",
}
// StyleRounded renders a Table like below:
// ╭─────┬────────────┬───────────┬────────┬─────────────────────────────╮
// │ # │ FIRST NAME │ LAST NAME │ SALARY │ │
// ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤
// │ 1 │ Arya │ Stark │ 3000 │ │
// │ 20 │ Jon │ Snow │ 2000 │ You know nothing, Jon Snow! │
// │ 300 │ Tyrion │ Lannister │ 5000 │ │
// ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤
// │ │ │ TOTAL │ 10000 │ │
// ╰─────┴────────────┴───────────┴────────┴─────────────────────────────╯
StyleRounded = Style{
BoxBottomLeft: text.BoxBottomLeftRounded,
BoxBottomRight: text.BoxBottomRightRounded,
BoxBottomSeparator: text.BoxBottomSeparator,
BoxLeft: text.BoxLeft,
BoxLeftSeparator: text.BoxLeftSeparator,
BoxMiddleHorizontal: text.BoxHorizontal,
BoxMiddleSeparator: text.BoxSeparator,
BoxMiddleVertical: text.BoxVertical,
BoxPaddingLeft: " ",
BoxPaddingRight: " ",
BoxRight: text.BoxRight,
BoxRightSeparator: text.BoxRightSeparator,
BoxTopLeft: text.BoxTopLeftRounded,
BoxTopRight: text.BoxTopRightRounded,
BoxTopSeparator: text.BoxTopSeparator,
BoxUnfinishedRow: " " + text.BoxUnfinishedLine,
FormatFooter: text.FormatUpper,
FormatHeader: text.FormatUpper,
FormatRows: text.FormatDefault,
Name: "StyleRounded",
}
// styleTest renders a Table like below:
// (-----^------------^-----------^--------^-----------------------------)
// [< #>|<FIRST NAME>|<LAST NAME>|<SALARY>|< >]
// {-----+------------+-----------+--------+-----------------------------}
// [< 1>|<Arya >|<Stark >|< 3000>|< >]
// [< 20>|<Jon >|<Snow >|< 2000>|<You know nothing, Jon Snow!>]
// [<300>|<Tyrion >|<Lannister>|< 5000>|< >]
// {-----+------------+-----------+--------+-----------------------------}
// [< >|< >|<TOTAL >|< 10000>|< >]
// \-----v------------v-----------v--------v-----------------------------/
styleTest = Style{
BoxBottomLeft: "\\",
BoxBottomRight: "/",
BoxBottomSeparator: "v",
BoxLeft: "[",
BoxLeftSeparator: "{",
BoxMiddleHorizontal: "-",
BoxMiddleSeparator: "+",
BoxMiddleVertical: "|",
BoxPaddingLeft: "<",
BoxPaddingRight: ">",
BoxRight: "]",
BoxRightSeparator: "}",
BoxTopLeft: "(",
BoxTopRight: ")",
BoxTopSeparator: "^",
BoxUnfinishedRow: " ~~~",
FormatFooter: text.FormatUpper,
FormatHeader: text.FormatUpper,
FormatRows: text.FormatDefault,
Name: "styleTest",
}
)