contracts/lib/forge-std/src/StdStyle.sol 10.2 K raw
1
// SPDX-License-Identifier: MIT
2
pragma solidity >=0.4.22 <0.9.0;
3
4
import {VmSafe} from "./Vm.sol";
5
6
library StdStyle {
7
    VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
8
9
    string constant RED = "\u001b[91m";
10
    string constant GREEN = "\u001b[92m";
11
    string constant YELLOW = "\u001b[93m";
12
    string constant BLUE = "\u001b[94m";
13
    string constant MAGENTA = "\u001b[95m";
14
    string constant CYAN = "\u001b[96m";
15
    string constant BOLD = "\u001b[1m";
16
    string constant DIM = "\u001b[2m";
17
    string constant ITALIC = "\u001b[3m";
18
    string constant UNDERLINE = "\u001b[4m";
19
    string constant INVERSE = "\u001b[7m";
20
    string constant RESET = "\u001b[0m";
21
22
    function styleConcat(string memory style, string memory self) private pure returns (string memory) {
23
        return string(abi.encodePacked(style, self, RESET));
24
    }
25
26
    function red(string memory self) internal pure returns (string memory) {
27
        return styleConcat(RED, self);
28
    }
29
30
    function red(uint256 self) internal pure returns (string memory) {
31
        return red(vm.toString(self));
32
    }
33
34
    function red(int256 self) internal pure returns (string memory) {
35
        return red(vm.toString(self));
36
    }
37
38
    function red(address self) internal pure returns (string memory) {
39
        return red(vm.toString(self));
40
    }
41
42
    function red(bool self) internal pure returns (string memory) {
43
        return red(vm.toString(self));
44
    }
45
46
    function redBytes(bytes memory self) internal pure returns (string memory) {
47
        return red(vm.toString(self));
48
    }
49
50
    function redBytes32(bytes32 self) internal pure returns (string memory) {
51
        return red(vm.toString(self));
52
    }
53
54
    function green(string memory self) internal pure returns (string memory) {
55
        return styleConcat(GREEN, self);
56
    }
57
58
    function green(uint256 self) internal pure returns (string memory) {
59
        return green(vm.toString(self));
60
    }
61
62
    function green(int256 self) internal pure returns (string memory) {
63
        return green(vm.toString(self));
64
    }
65
66
    function green(address self) internal pure returns (string memory) {
67
        return green(vm.toString(self));
68
    }
69
70
    function green(bool self) internal pure returns (string memory) {
71
        return green(vm.toString(self));
72
    }
73
74
    function greenBytes(bytes memory self) internal pure returns (string memory) {
75
        return green(vm.toString(self));
76
    }
77
78
    function greenBytes32(bytes32 self) internal pure returns (string memory) {
79
        return green(vm.toString(self));
80
    }
81
82
    function yellow(string memory self) internal pure returns (string memory) {
83
        return styleConcat(YELLOW, self);
84
    }
85
86
    function yellow(uint256 self) internal pure returns (string memory) {
87
        return yellow(vm.toString(self));
88
    }
89
90
    function yellow(int256 self) internal pure returns (string memory) {
91
        return yellow(vm.toString(self));
92
    }
93
94
    function yellow(address self) internal pure returns (string memory) {
95
        return yellow(vm.toString(self));
96
    }
97
98
    function yellow(bool self) internal pure returns (string memory) {
99
        return yellow(vm.toString(self));
100
    }
101
102
    function yellowBytes(bytes memory self) internal pure returns (string memory) {
103
        return yellow(vm.toString(self));
104
    }
105
106
    function yellowBytes32(bytes32 self) internal pure returns (string memory) {
107
        return yellow(vm.toString(self));
108
    }
109
110
    function blue(string memory self) internal pure returns (string memory) {
111
        return styleConcat(BLUE, self);
112
    }
113
114
    function blue(uint256 self) internal pure returns (string memory) {
115
        return blue(vm.toString(self));
116
    }
117
118
    function blue(int256 self) internal pure returns (string memory) {
119
        return blue(vm.toString(self));
120
    }
121
122
    function blue(address self) internal pure returns (string memory) {
123
        return blue(vm.toString(self));
124
    }
125
126
    function blue(bool self) internal pure returns (string memory) {
127
        return blue(vm.toString(self));
128
    }
129
130
    function blueBytes(bytes memory self) internal pure returns (string memory) {
131
        return blue(vm.toString(self));
132
    }
133
134
    function blueBytes32(bytes32 self) internal pure returns (string memory) {
135
        return blue(vm.toString(self));
136
    }
137
138
    function magenta(string memory self) internal pure returns (string memory) {
139
        return styleConcat(MAGENTA, self);
140
    }
141
142
    function magenta(uint256 self) internal pure returns (string memory) {
143
        return magenta(vm.toString(self));
144
    }
145
146
    function magenta(int256 self) internal pure returns (string memory) {
147
        return magenta(vm.toString(self));
148
    }
149
150
    function magenta(address self) internal pure returns (string memory) {
151
        return magenta(vm.toString(self));
152
    }
153
154
    function magenta(bool self) internal pure returns (string memory) {
155
        return magenta(vm.toString(self));
156
    }
157
158
    function magentaBytes(bytes memory self) internal pure returns (string memory) {
159
        return magenta(vm.toString(self));
160
    }
161
162
    function magentaBytes32(bytes32 self) internal pure returns (string memory) {
163
        return magenta(vm.toString(self));
164
    }
165
166
    function cyan(string memory self) internal pure returns (string memory) {
167
        return styleConcat(CYAN, self);
168
    }
169
170
    function cyan(uint256 self) internal pure returns (string memory) {
171
        return cyan(vm.toString(self));
172
    }
173
174
    function cyan(int256 self) internal pure returns (string memory) {
175
        return cyan(vm.toString(self));
176
    }
177
178
    function cyan(address self) internal pure returns (string memory) {
179
        return cyan(vm.toString(self));
180
    }
181
182
    function cyan(bool self) internal pure returns (string memory) {
183
        return cyan(vm.toString(self));
184
    }
185
186
    function cyanBytes(bytes memory self) internal pure returns (string memory) {
187
        return cyan(vm.toString(self));
188
    }
189
190
    function cyanBytes32(bytes32 self) internal pure returns (string memory) {
191
        return cyan(vm.toString(self));
192
    }
193
194
    function bold(string memory self) internal pure returns (string memory) {
195
        return styleConcat(BOLD, self);
196
    }
197
198
    function bold(uint256 self) internal pure returns (string memory) {
199
        return bold(vm.toString(self));
200
    }
201
202
    function bold(int256 self) internal pure returns (string memory) {
203
        return bold(vm.toString(self));
204
    }
205
206
    function bold(address self) internal pure returns (string memory) {
207
        return bold(vm.toString(self));
208
    }
209
210
    function bold(bool self) internal pure returns (string memory) {
211
        return bold(vm.toString(self));
212
    }
213
214
    function boldBytes(bytes memory self) internal pure returns (string memory) {
215
        return bold(vm.toString(self));
216
    }
217
218
    function boldBytes32(bytes32 self) internal pure returns (string memory) {
219
        return bold(vm.toString(self));
220
    }
221
222
    function dim(string memory self) internal pure returns (string memory) {
223
        return styleConcat(DIM, self);
224
    }
225
226
    function dim(uint256 self) internal pure returns (string memory) {
227
        return dim(vm.toString(self));
228
    }
229
230
    function dim(int256 self) internal pure returns (string memory) {
231
        return dim(vm.toString(self));
232
    }
233
234
    function dim(address self) internal pure returns (string memory) {
235
        return dim(vm.toString(self));
236
    }
237
238
    function dim(bool self) internal pure returns (string memory) {
239
        return dim(vm.toString(self));
240
    }
241
242
    function dimBytes(bytes memory self) internal pure returns (string memory) {
243
        return dim(vm.toString(self));
244
    }
245
246
    function dimBytes32(bytes32 self) internal pure returns (string memory) {
247
        return dim(vm.toString(self));
248
    }
249
250
    function italic(string memory self) internal pure returns (string memory) {
251
        return styleConcat(ITALIC, self);
252
    }
253
254
    function italic(uint256 self) internal pure returns (string memory) {
255
        return italic(vm.toString(self));
256
    }
257
258
    function italic(int256 self) internal pure returns (string memory) {
259
        return italic(vm.toString(self));
260
    }
261
262
    function italic(address self) internal pure returns (string memory) {
263
        return italic(vm.toString(self));
264
    }
265
266
    function italic(bool self) internal pure returns (string memory) {
267
        return italic(vm.toString(self));
268
    }
269
270
    function italicBytes(bytes memory self) internal pure returns (string memory) {
271
        return italic(vm.toString(self));
272
    }
273
274
    function italicBytes32(bytes32 self) internal pure returns (string memory) {
275
        return italic(vm.toString(self));
276
    }
277
278
    function underline(string memory self) internal pure returns (string memory) {
279
        return styleConcat(UNDERLINE, self);
280
    }
281
282
    function underline(uint256 self) internal pure returns (string memory) {
283
        return underline(vm.toString(self));
284
    }
285
286
    function underline(int256 self) internal pure returns (string memory) {
287
        return underline(vm.toString(self));
288
    }
289
290
    function underline(address self) internal pure returns (string memory) {
291
        return underline(vm.toString(self));
292
    }
293
294
    function underline(bool self) internal pure returns (string memory) {
295
        return underline(vm.toString(self));
296
    }
297
298
    function underlineBytes(bytes memory self) internal pure returns (string memory) {
299
        return underline(vm.toString(self));
300
    }
301
302
    function underlineBytes32(bytes32 self) internal pure returns (string memory) {
303
        return underline(vm.toString(self));
304
    }
305
306
    function inverse(string memory self) internal pure returns (string memory) {
307
        return styleConcat(INVERSE, self);
308
    }
309
310
    function inverse(uint256 self) internal pure returns (string memory) {
311
        return inverse(vm.toString(self));
312
    }
313
314
    function inverse(int256 self) internal pure returns (string memory) {
315
        return inverse(vm.toString(self));
316
    }
317
318
    function inverse(address self) internal pure returns (string memory) {
319
        return inverse(vm.toString(self));
320
    }
321
322
    function inverse(bool self) internal pure returns (string memory) {
323
        return inverse(vm.toString(self));
324
    }
325
326
    function inverseBytes(bytes memory self) internal pure returns (string memory) {
327
        return inverse(vm.toString(self));
328
    }
329
330
    function inverseBytes32(bytes32 self) internal pure returns (string memory) {
331
        return inverse(vm.toString(self));
332
    }
333
}