Skip to content

Commit acc68d9

Browse files
committed
simplify get_formatted_subtitle_label
1 parent aaa80b1 commit acc68d9

File tree

1 file changed

+19
-72
lines changed

1 file changed

+19
-72
lines changed

Diff for: src/onefetch/info.rs

+19-72
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ impl std::fmt::Display for Info {
5454
if !self.config.disabled_fields.project {
5555
let branches_tags_str = self.get_branches_and_tags_field();
5656

57-
let project_str = &self.get_formatted_subtitle_label(
58-
"Project",
59-
self.color_set.subtitle,
60-
self.color_set.colon,
61-
);
57+
let project_str = &self.get_formatted_subtitle_label("Project");
6258

6359
writeln!(
6460
f,
@@ -73,11 +69,7 @@ impl std::fmt::Display for Info {
7369
writeln!(
7470
f,
7571
"{}{}",
76-
&self.get_formatted_subtitle_label(
77-
"HEAD",
78-
self.color_set.subtitle,
79-
self.color_set.colon,
80-
),
72+
&self.get_formatted_subtitle_label("HEAD"),
8173
&self.current_commit.to_string().color(self.color_set.info),
8274
)?;
8375
}
@@ -86,11 +78,7 @@ impl std::fmt::Display for Info {
8678
writeln!(
8779
f,
8880
"{}{}",
89-
&self.get_formatted_subtitle_label(
90-
"Pending",
91-
self.color_set.subtitle,
92-
self.color_set.colon,
93-
),
81+
&self.get_formatted_subtitle_label("Pending"),
9482
&self.pending.color(self.color_set.info),
9583
)?;
9684
}
@@ -99,11 +87,7 @@ impl std::fmt::Display for Info {
9987
writeln!(
10088
f,
10189
"{}{}",
102-
&self.get_formatted_subtitle_label(
103-
"Version",
104-
self.color_set.subtitle,
105-
self.color_set.colon,
106-
),
90+
&self.get_formatted_subtitle_label("Version"),
10791
&self.version.color(self.color_set.info),
10892
)?;
10993
}
@@ -112,11 +96,7 @@ impl std::fmt::Display for Info {
11296
writeln!(
11397
f,
11498
"{}{}",
115-
&self.get_formatted_subtitle_label(
116-
"Created",
117-
self.color_set.subtitle,
118-
self.color_set.colon,
119-
),
99+
&self.get_formatted_subtitle_label("Created"),
120100
&self.creation_date.color(self.color_set.info),
121101
)?;
122102
}
@@ -133,11 +113,7 @@ impl std::fmt::Display for Info {
133113
writeln!(
134114
f,
135115
"{}{}",
136-
&self.get_formatted_subtitle_label(
137-
title,
138-
self.color_set.subtitle,
139-
self.color_set.colon,
140-
),
116+
&self.get_formatted_subtitle_label(title),
141117
languages_str.color(self.color_set.info)
142118
)?;
143119
}
@@ -154,11 +130,7 @@ impl std::fmt::Display for Info {
154130
write!(
155131
f,
156132
"{}{}",
157-
&self.get_formatted_subtitle_label(
158-
title,
159-
self.color_set.subtitle,
160-
self.color_set.colon,
161-
),
133+
&self.get_formatted_subtitle_label(title),
162134
author_str.color(self.color_set.info),
163135
)?;
164136
}
@@ -167,11 +139,7 @@ impl std::fmt::Display for Info {
167139
writeln!(
168140
f,
169141
"{}{}",
170-
&self.get_formatted_subtitle_label(
171-
"Last change",
172-
self.color_set.subtitle,
173-
self.color_set.colon,
174-
),
142+
&self.get_formatted_subtitle_label("Last change"),
175143
&self.last_change.color(self.color_set.info),
176144
)?;
177145
}
@@ -180,11 +148,7 @@ impl std::fmt::Display for Info {
180148
writeln!(
181149
f,
182150
"{}{}",
183-
&self.get_formatted_subtitle_label(
184-
"Repo",
185-
self.color_set.subtitle,
186-
self.color_set.colon,
187-
),
151+
&self.get_formatted_subtitle_label("Repo"),
188152
&self.repo_url.color(self.color_set.info),
189153
)?;
190154
}
@@ -193,11 +157,7 @@ impl std::fmt::Display for Info {
193157
writeln!(
194158
f,
195159
"{}{}",
196-
&self.get_formatted_subtitle_label(
197-
"Commits",
198-
self.color_set.subtitle,
199-
self.color_set.colon,
200-
),
160+
&self.get_formatted_subtitle_label("Commits"),
201161
&self.commits.color(self.color_set.info),
202162
)?;
203163
}
@@ -206,11 +166,7 @@ impl std::fmt::Display for Info {
206166
writeln!(
207167
f,
208168
"{} {}",
209-
&self.get_formatted_subtitle_label(
210-
"Lines of code",
211-
self.color_set.subtitle,
212-
self.color_set.colon,
213-
),
169+
&self.get_formatted_subtitle_label("Lines of code"),
214170
&self.number_of_lines.to_string().color(self.color_set.info),
215171
)?;
216172
}
@@ -219,11 +175,7 @@ impl std::fmt::Display for Info {
219175
writeln!(
220176
f,
221177
"{}{}",
222-
&self.get_formatted_subtitle_label(
223-
"Size",
224-
self.color_set.subtitle,
225-
self.color_set.colon,
226-
),
178+
&self.get_formatted_subtitle_label("Size"),
227179
&self.repo_size.color(self.color_set.info),
228180
)?;
229181
}
@@ -232,11 +184,7 @@ impl std::fmt::Display for Info {
232184
writeln!(
233185
f,
234186
"{}{}",
235-
&self.get_formatted_subtitle_label(
236-
"License",
237-
self.color_set.subtitle,
238-
self.color_set.colon,
239-
),
187+
&self.get_formatted_subtitle_label("License"),
240188
&self.license.color(self.color_set.info),
241189
)?;
242190
}
@@ -698,13 +646,12 @@ impl Info {
698646
Some(color)
699647
}
700648

701-
fn get_formatted_subtitle_label(
702-
&self,
703-
label: &str,
704-
color: Color,
705-
colon_clr: Color,
706-
) -> ColoredString {
707-
let formatted_label = format!("{}{} ", label.color(color), ":".color(colon_clr));
649+
fn get_formatted_subtitle_label(&self, label: &str) -> ColoredString {
650+
let formatted_label = format!(
651+
"{}{} ",
652+
label.color(self.color_set.subtitle),
653+
":".color(self.color_set.colon)
654+
);
708655
self.bold(&formatted_label)
709656
}
710657

0 commit comments

Comments
 (0)