@@ -95,50 +95,76 @@ impl std::fmt::Display for Info {
95
95
format ! ( "({}, {})" , branches_str, tags_str)
96
96
} ;
97
97
98
- let project_str = & self . get_formatted_subtitle_label ( "Project" , self . color_set . subtitle , self . color_set . colon ) ;
98
+ let project_str = & self . get_formatted_subtitle_label (
99
+ "Project" ,
100
+ self . color_set . subtitle ,
101
+ self . color_set . colon ,
102
+ ) ;
99
103
100
104
writeln ! (
101
105
f,
102
106
"{}{} {}" ,
103
- project_str, self . project_name. color( self . color_set. info) , branches_tags_str. color( self . color_set. info)
107
+ project_str,
108
+ self . project_name. color( self . color_set. info) ,
109
+ branches_tags_str. color( self . color_set. info)
104
110
) ?;
105
111
}
106
112
107
113
if !self . config . disabled_fields . head {
108
114
write_buf (
109
115
f,
110
- & self . get_formatted_subtitle_label ( "HEAD" , self . color_set . subtitle , self . color_set . colon ) ,
116
+ & self . get_formatted_subtitle_label (
117
+ "HEAD" ,
118
+ self . color_set . subtitle ,
119
+ self . color_set . colon ,
120
+ ) ,
111
121
& self . current_commit . to_string ( ) . color ( self . color_set . info ) ,
112
122
) ?;
113
123
}
114
124
115
125
if !self . config . disabled_fields . pending && self . pending != "" {
116
126
write_buf (
117
127
f,
118
- & self . get_formatted_subtitle_label ( "Pending" , self . color_set . subtitle , self . color_set . colon ) ,
128
+ & self . get_formatted_subtitle_label (
129
+ "Pending" ,
130
+ self . color_set . subtitle ,
131
+ self . color_set . colon ,
132
+ ) ,
119
133
& self . pending . color ( self . color_set . info ) ,
120
134
) ?;
121
135
}
122
136
123
137
if !self . config . disabled_fields . version {
124
138
write_buf (
125
139
f,
126
- & self . get_formatted_subtitle_label ( "Version" , self . color_set . subtitle , self . color_set . colon ) ,
140
+ & self . get_formatted_subtitle_label (
141
+ "Version" ,
142
+ self . color_set . subtitle ,
143
+ self . color_set . colon ,
144
+ ) ,
127
145
& self . version . color ( self . color_set . info ) ,
128
146
) ?;
129
147
}
130
148
131
149
if !self . config . disabled_fields . created {
132
150
write_buf (
133
151
f,
134
- & self . get_formatted_subtitle_label ( "Created" , self . color_set . subtitle , self . color_set . colon ) ,
152
+ & self . get_formatted_subtitle_label (
153
+ "Created" ,
154
+ self . color_set . subtitle ,
155
+ self . color_set . colon ,
156
+ ) ,
135
157
& self . creation_date . color ( self . color_set . info ) ,
136
158
) ?;
137
159
}
138
160
139
161
if !self . config . disabled_fields . languages && !self . languages . is_empty ( ) {
140
162
if self . languages . len ( ) > 1 {
141
- let title = & self . get_formatted_subtitle_label ( "Languages" , self . color_set . subtitle , self . color_set . colon ) ;
163
+ let title = & self . get_formatted_subtitle_label (
164
+ "Languages" ,
165
+ self . color_set . subtitle ,
166
+ self . color_set . colon ,
167
+ ) ;
142
168
let pad = " " . repeat ( title. len ( ) ) ;
143
169
let mut s = String :: from ( "" ) ;
144
170
let languages: Vec < ( String , f64 ) > = {
@@ -165,8 +191,15 @@ impl std::fmt::Display for Info {
165
191
} else {
166
192
write_buf (
167
193
f,
168
- & self . get_formatted_subtitle_label ( "Language" , self . color_set . subtitle , self . color_set . colon ) ,
169
- & self . dominant_language . to_string ( ) . color ( self . color_set . info ) ,
194
+ & self . get_formatted_subtitle_label (
195
+ "Language" ,
196
+ self . color_set . subtitle ,
197
+ self . color_set . colon ,
198
+ ) ,
199
+ & self
200
+ . dominant_language
201
+ . to_string ( )
202
+ . color ( self . color_set . info ) ,
170
203
) ?;
171
204
} ;
172
205
}
@@ -181,7 +214,11 @@ impl std::fmt::Display for Info {
181
214
writeln ! (
182
215
f,
183
216
"{}{}{} {} {}" ,
184
- & self . get_formatted_subtitle_label( title, self . color_set. subtitle, self . color_set. colon) ,
217
+ & self . get_formatted_subtitle_label(
218
+ title,
219
+ self . color_set. subtitle,
220
+ self . color_set. colon
221
+ ) ,
185
222
self . authors[ 0 ] . 2 . to_string( ) . color( self . color_set. info) ,
186
223
"%" . color( self . color_set. info) ,
187
224
self . authors[ 0 ] . 0 . to_string( ) . color( self . color_set. info) ,
@@ -206,47 +243,71 @@ impl std::fmt::Display for Info {
206
243
if !self . config . disabled_fields . last_change {
207
244
write_buf (
208
245
f,
209
- & self . get_formatted_subtitle_label ( "Last change" , self . color_set . subtitle , self . color_set . colon ) ,
246
+ & self . get_formatted_subtitle_label (
247
+ "Last change" ,
248
+ self . color_set . subtitle ,
249
+ self . color_set . colon ,
250
+ ) ,
210
251
& self . last_change . color ( self . color_set . info ) ,
211
252
) ?;
212
253
}
213
254
214
255
if !self . config . disabled_fields . repo {
215
256
write_buf (
216
257
f,
217
- & self . get_formatted_subtitle_label ( "Repo" , self . color_set . subtitle , self . color_set . colon ) ,
258
+ & self . get_formatted_subtitle_label (
259
+ "Repo" ,
260
+ self . color_set . subtitle ,
261
+ self . color_set . colon ,
262
+ ) ,
218
263
& self . repo_url . color ( self . color_set . info ) ,
219
264
) ?;
220
265
}
221
266
222
267
if !self . config . disabled_fields . commits {
223
268
write_buf (
224
269
f,
225
- & self . get_formatted_subtitle_label ( "Commits" , self . color_set . subtitle , self . color_set . colon ) ,
270
+ & self . get_formatted_subtitle_label (
271
+ "Commits" ,
272
+ self . color_set . subtitle ,
273
+ self . color_set . colon ,
274
+ ) ,
226
275
& self . commits . color ( self . color_set . info ) ,
227
276
) ?;
228
277
}
229
278
230
279
if !self . config . disabled_fields . lines_of_code {
231
280
write_buf (
232
281
f,
233
- & self . get_formatted_subtitle_label ( "Lines of code" , self . color_set . subtitle , self . color_set . colon ) ,
282
+ & self . get_formatted_subtitle_label (
283
+ "Lines of code" ,
284
+ self . color_set . subtitle ,
285
+ self . color_set . colon ,
286
+ ) ,
234
287
& self . number_of_lines . to_string ( ) . color ( self . color_set . info ) ,
235
288
) ?;
236
289
}
237
290
238
291
if !self . config . disabled_fields . size {
239
292
write_buf (
240
293
f,
241
- & self . get_formatted_subtitle_label ( "Size" , self . color_set . subtitle , self . color_set . colon ) ,
294
+ & self . get_formatted_subtitle_label (
295
+ "Size" ,
296
+ self . color_set . subtitle ,
297
+ self . color_set . colon ,
298
+ ) ,
242
299
& self . repo_size . color ( self . color_set . info ) ,
243
300
) ?;
244
301
}
245
302
246
303
if !self . config . disabled_fields . license {
247
304
write_buf (
248
305
f,
249
- & self . get_formatted_subtitle_label ( "License" , self . color_set . subtitle , self . color_set . colon ) ,
306
+ & self . get_formatted_subtitle_label (
307
+ "License" ,
308
+ self . color_set . subtitle ,
309
+ self . color_set . colon ,
310
+ ) ,
250
311
& self . license . color ( self . color_set . info ) ,
251
312
) ?;
252
313
}
@@ -717,7 +778,12 @@ impl Info {
717
778
Some ( color)
718
779
}
719
780
720
- fn get_formatted_subtitle_label ( & self , label : & str , color : Color , colon_clr : Color ) -> ColoredString {
781
+ fn get_formatted_subtitle_label (
782
+ & self ,
783
+ label : & str ,
784
+ color : Color ,
785
+ colon_clr : Color ,
786
+ ) -> ColoredString {
721
787
let formatted_label = format ! ( "{}{} " , label. color( color) , ":" . color( colon_clr) ) ;
722
788
if self . config . no_bold {
723
789
formatted_label. normal ( )
@@ -729,7 +795,7 @@ impl Info {
729
795
fn get_color_set ( text_colors : & [ String ] ) -> TextColor {
730
796
let mut custom_color: Vec < Color > = text_colors
731
797
. iter ( )
732
- . map ( |color_num|{
798
+ . map ( |color_num| {
733
799
let custom = Info :: num_to_color ( color_num) ;
734
800
match custom {
735
801
Some ( custom) => custom,
@@ -746,7 +812,7 @@ impl Info {
746
812
}
747
813
}
748
814
749
- let color_set: TextColor = TextColor {
815
+ let color_set: TextColor = TextColor {
750
816
title : custom_color[ 0 ] ,
751
817
tilde : custom_color[ 1 ] ,
752
818
underline : custom_color[ 2 ] ,
@@ -764,4 +830,4 @@ fn write_buf<T: std::fmt::Display>(
764
830
content : T ,
765
831
) -> std:: fmt:: Result {
766
832
writeln ! ( buffer, "{}{}" , title, content)
767
- }
833
+ }
0 commit comments