Skip to content

Commit d9e8184

Browse files
committed
better var and fn naming
1 parent 6c4f409 commit d9e8184

File tree

4 files changed

+48
-45
lines changed

4 files changed

+48
-45
lines changed

Diff for: src/onefetch/cli.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct Cli {
2121
pub no_bold: bool,
2222
pub image: Option<DynamicImage>,
2323
pub image_backend: Option<Box<dyn image_backends::ImageBackend>>,
24-
pub image_colors: usize,
24+
pub image_color_resolution: usize,
2525
pub no_merges: bool,
2626
pub no_color_palette: bool,
2727
pub number_of_authors: usize,
@@ -258,7 +258,7 @@ impl Cli {
258258
return Err("Could not detect a supported image backend".into());
259259
}
260260

261-
let image_colors = if let Some(value) = matches.value_of("color-resolution") {
261+
let image_color_resolution = if let Some(value) = matches.value_of("color-resolution") {
262262
usize::from_str(value).unwrap()
263263
} else {
264264
16
@@ -305,7 +305,7 @@ impl Cli {
305305
no_bold,
306306
image,
307307
image_backend,
308-
image_colors,
308+
image_color_resolution,
309309
no_merges,
310310
no_color_palette,
311311
number_of_authors,

Diff for: src/onefetch/cli_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ impl<W: Write> Printer<W> {
3737
.add_image(
3838
info_lines.map(|s| format!("{}{}", center_pad, s)).collect(),
3939
custom_image,
40-
self.info.config.image_colors,
40+
self.info.config.image_color_resolution,
4141
)
4242
.chain_err(|| "Error while drawing image")?,
4343
);
4444
} else {
4545
let mut logo_lines = if let Some(custom_ascii) = &self.info.config.ascii_input {
4646
AsciiArt::new(custom_ascii, &colors, !self.info.config.no_bold)
4747
} else {
48-
AsciiArt::new(self.get_ascii(), &self.info.colors, !self.info.config.no_bold)
48+
AsciiArt::new(self.get_ascii(), &self.info.ascii_colors, !self.info.config.no_bold)
4949
};
5050

5151
loop {

Diff for: src/onefetch/info.rs

+42-39
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ pub struct Info {
2929
number_of_tags: usize,
3030
number_of_branches: usize,
3131
license: String,
32-
pub colors: Vec<Color>,
33-
pub color_set: TextColor,
32+
pub ascii_colors: Vec<Color>,
33+
pub text_colors: TextColor,
3434
pub config: Cli,
3535
}
3636

@@ -42,14 +42,14 @@ impl std::fmt::Display for Info {
4242
writeln!(
4343
f,
4444
"{} {} {}",
45-
&self.bold(&self.git_username).color(self.color_set.title),
46-
&self.bold("~").color(self.color_set.tilde),
47-
&self.bold(&self.git_version).color(self.color_set.title)
45+
&self.bold(&self.git_username).color(self.text_colors.title),
46+
&self.bold("~").color(self.text_colors.tilde),
47+
&self.bold(&self.git_version).color(self.text_colors.title)
4848
)?;
4949

5050
let separator = "-".repeat(git_info_length);
5151

52-
writeln!(f, "{}", separator.color(self.color_set.underline))?;
52+
writeln!(f, "{}", separator.color(self.text_colors.underline))?;
5353
}
5454

5555
if !self.config.disabled_fields.project {
@@ -61,8 +61,8 @@ impl std::fmt::Display for Info {
6161
f,
6262
"{}{} {}",
6363
project_str,
64-
self.project_name.color(self.color_set.info),
65-
branches_tags_str.color(self.color_set.info)
64+
self.project_name.color(self.text_colors.info),
65+
branches_tags_str.color(self.text_colors.info)
6666
)?;
6767
}
6868

@@ -71,7 +71,7 @@ impl std::fmt::Display for Info {
7171
f,
7272
"{}{}",
7373
&self.get_formatted_subtitle_label("HEAD"),
74-
&self.current_commit.to_string().color(self.color_set.info),
74+
&self.current_commit.to_string().color(self.text_colors.info),
7575
)?;
7676
}
7777

@@ -80,7 +80,7 @@ impl std::fmt::Display for Info {
8080
f,
8181
"{}{}",
8282
&self.get_formatted_subtitle_label("Pending"),
83-
&self.pending.color(self.color_set.info),
83+
&self.pending.color(self.text_colors.info),
8484
)?;
8585
}
8686

@@ -89,7 +89,7 @@ impl std::fmt::Display for Info {
8989
f,
9090
"{}{}",
9191
&self.get_formatted_subtitle_label("Version"),
92-
&self.version.color(self.color_set.info),
92+
&self.version.color(self.text_colors.info),
9393
)?;
9494
}
9595

@@ -98,7 +98,7 @@ impl std::fmt::Display for Info {
9898
f,
9999
"{}{}",
100100
&self.get_formatted_subtitle_label("Created"),
101-
&self.creation_date.color(self.color_set.info),
101+
&self.creation_date.color(self.text_colors.info),
102102
)?;
103103
}
104104

@@ -111,7 +111,7 @@ impl std::fmt::Display for Info {
111111
f,
112112
"{}{}",
113113
&self.get_formatted_subtitle_label(title),
114-
languages_str.color(self.color_set.info)
114+
languages_str.color(self.text_colors.info)
115115
)?;
116116
}
117117

@@ -120,7 +120,7 @@ impl std::fmt::Display for Info {
120120
f,
121121
"{}{}",
122122
&self.get_formatted_subtitle_label("Dependencies"),
123-
&self.dependencies.color(self.color_set.info),
123+
&self.dependencies.color(self.text_colors.info),
124124
)?;
125125
}
126126

@@ -133,7 +133,7 @@ impl std::fmt::Display for Info {
133133
f,
134134
"{}{}",
135135
&self.get_formatted_subtitle_label(title),
136-
author_str.color(self.color_set.info),
136+
author_str.color(self.text_colors.info),
137137
)?;
138138
}
139139

@@ -142,7 +142,7 @@ impl std::fmt::Display for Info {
142142
f,
143143
"{}{}",
144144
&self.get_formatted_subtitle_label("Last change"),
145-
&self.last_change.color(self.color_set.info),
145+
&self.last_change.color(self.text_colors.info),
146146
)?;
147147
}
148148

@@ -151,7 +151,7 @@ impl std::fmt::Display for Info {
151151
f,
152152
"{}{}",
153153
&self.get_formatted_subtitle_label("Repo"),
154-
&self.repo_url.color(self.color_set.info),
154+
&self.repo_url.color(self.text_colors.info),
155155
)?;
156156
}
157157

@@ -160,7 +160,7 @@ impl std::fmt::Display for Info {
160160
f,
161161
"{}{}",
162162
&self.get_formatted_subtitle_label("Commits"),
163-
&self.commits.color(self.color_set.info),
163+
&self.commits.color(self.text_colors.info),
164164
)?;
165165
}
166166

@@ -169,7 +169,7 @@ impl std::fmt::Display for Info {
169169
f,
170170
"{}{}",
171171
&self.get_formatted_subtitle_label("Lines of code"),
172-
&self.lines_of_code.to_string().color(self.color_set.info),
172+
&self.lines_of_code.to_string().color(self.text_colors.info),
173173
)?;
174174
}
175175

@@ -178,7 +178,7 @@ impl std::fmt::Display for Info {
178178
f,
179179
"{}{}",
180180
&self.get_formatted_subtitle_label("Size"),
181-
&self.repo_size.color(self.color_set.info),
181+
&self.repo_size.color(self.text_colors.info),
182182
)?;
183183
}
184184

@@ -187,7 +187,7 @@ impl std::fmt::Display for Info {
187187
f,
188188
"{}{}",
189189
&self.get_formatted_subtitle_label("License"),
190-
&self.license.color(self.color_set.info),
190+
&self.license.color(self.text_colors.info),
191191
)?;
192192
}
193193

@@ -233,13 +233,13 @@ impl Info {
233233
let project_license = Detector::new()?.get_project_license(workdir_str);
234234
let dominant_language = Language::get_dominant_language(&languages_stats);
235235
let dependencies = deps::DependencyDetector::new().get_dependencies(workdir_str)?;
236-
let colors = Info::get_colors(
236+
let ascii_colors = Info::get_ascii_colors(
237237
&config.ascii_language,
238238
&dominant_language,
239239
&config.ascii_colors,
240240
config.true_color,
241241
);
242-
let color_set = TextColor::get_text_color_set(&config.text_colors, &colors);
242+
let text_colors = TextColor::get_text_colors(&config.text_colors, &ascii_colors);
243243

244244
Ok(Info {
245245
git_version: git_v,
@@ -261,8 +261,8 @@ impl Info {
261261
number_of_tags,
262262
number_of_branches,
263263
license: project_license?,
264-
colors,
265-
color_set,
264+
ascii_colors,
265+
text_colors,
266266
config,
267267
})
268268
}
@@ -555,7 +555,7 @@ impl Info {
555555
Ok(output)
556556
}
557557

558-
fn get_colors(
558+
fn get_ascii_colors(
559559
ascii_language: &Language,
560560
dominant_language: &Language,
561561
ascii_colors: &[String],
@@ -608,8 +608,11 @@ impl Info {
608608
}
609609

610610
fn get_formatted_subtitle_label(&self, label: &str) -> ColoredString {
611-
let formatted_label =
612-
format!("{}{} ", label.color(self.color_set.subtitle), ":".color(self.color_set.colon));
611+
let formatted_label = format!(
612+
"{}{} ",
613+
label.color(self.text_colors.subtitle),
614+
":".color(self.text_colors.colon)
615+
);
613616
self.bold(&formatted_label)
614617
}
615618

@@ -632,19 +635,19 @@ impl Info {
632635
if i == 0 {
633636
author_field.push_str(&format!(
634637
"{}{} {} {}\n",
635-
autor_contribution.to_string().color(self.color_set.info),
636-
"%".color(self.color_set.info),
637-
author_name.to_string().color(self.color_set.info),
638-
author_nbr_commits.to_string().color(self.color_set.info),
638+
autor_contribution.to_string().color(self.text_colors.info),
639+
"%".color(self.text_colors.info),
640+
author_name.to_string().color(self.text_colors.info),
641+
author_nbr_commits.to_string().color(self.text_colors.info),
639642
));
640643
} else {
641644
author_field.push_str(&format!(
642645
"{:<width$}{}{} {} {}\n",
643646
"",
644-
autor_contribution.to_string().color(self.color_set.info),
645-
"%".color(self.color_set.info),
646-
author_name.to_string().color(self.color_set.info),
647-
author_nbr_commits.to_string().color(self.color_set.info),
647+
autor_contribution.to_string().color(self.text_colors.info),
648+
"%".color(self.text_colors.info),
649+
author_name.to_string().color(self.text_colors.info),
650+
author_nbr_commits.to_string().color(self.text_colors.info),
648651
width = pad
649652
));
650653
}
@@ -671,19 +674,19 @@ impl Info {
671674
};
672675

673676
for (cnt, language) in languages.iter().enumerate() {
674-
let formatted_number = format!("{:.*}", 1, language.1).color(self.color_set.info);
677+
let formatted_number = format!("{:.*}", 1, language.1).color(self.text_colors.info);
675678
if cnt != 0 && cnt % 2 == 0 {
676679
language_field.push_str(&format!(
677680
"\n{:<width$}{} ({} %) ",
678681
"",
679-
language.0.color(self.color_set.info),
682+
language.0.color(self.text_colors.info),
680683
formatted_number,
681684
width = pad
682685
));
683686
} else {
684687
language_field.push_str(&format!(
685688
"{} ({} %) ",
686-
language.0.color(self.color_set.info),
689+
language.0.color(self.text_colors.info),
687690
formatted_number
688691
));
689692
}

Diff for: src/onefetch/text_color.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl TextColor {
2121
}
2222
}
2323

24-
pub fn get_text_color_set(text_colors: &[String], default_colors: &[Color]) -> TextColor {
24+
pub fn get_text_colors(text_colors: &[String], default_colors: &[Color]) -> TextColor {
2525
let mut text_color_set = TextColor::new(default_colors[0]);
2626
if !text_colors.is_empty() {
2727
let custom_color = text_colors

0 commit comments

Comments
 (0)