Skip to content

Commit 0515730

Browse files
committed
fix text coloring
1 parent 420bc28 commit 0515730

File tree

4 files changed

+13
-29
lines changed

4 files changed

+13
-29
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111

1212
<p align="center">[<a href="./docs/README.ja.md">日本語</a>]</p>
1313

14-
<img src="assets/react.png" align="right" height="240px">
14+
<img src="assets/screenshot-1.png" align="right" height="240px">
1515

1616
Onefetch is a command-line Git information tool written in `Rust` that displays project information and code statistics for a local Git repository directly on your terminal. The tool is completely offline - no network access is required.
1717

1818
By default, the repo's information is displayed alongside the dominant language's logo, but you can further configure onefetch to instead use an image - on supported terminals -, a text input or nothing at all.
1919

2020
It automatically detects open source licenses from texts and provides the user with valuable information like code distribution, pending changes, number of dependencies (by package manager), top contributors (by number of commits), size on disk, creation date, LOC (lines of code), etc.
2121

22-
<img src="assets/kubernetes.png" align="right" height="240px">
22+
<img src="assets/screenshot-2.png" align="right" height="240px">
2323

2424
Onefetch can be configured via command-line flags to display exactly what you want, the way you want it to: you can customize ASCII/Text formatting, disable info lines, ignore files & directories, output in multiple formats (Json, Yaml), etc.
2525

File renamed without changes.
File renamed without changes.

Diff for: src/info/mod.rs

+11-27
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,7 @@ impl std::fmt::Display for Info {
115115

116116
let languages_str = self.get_language_field(title);
117117

118-
writeln!(
119-
f,
120-
"{}{}",
121-
&self.get_formatted_subtitle_label(title),
122-
languages_str.color(self.text_colors.info)
123-
)?;
118+
writeln!(f, "{}{}", &self.get_formatted_subtitle_label(title), languages_str)?;
124119
}
125120

126121
if !self.config.disabled_fields.dependencies && !self.dependencies.is_empty() {
@@ -137,12 +132,7 @@ impl std::fmt::Display for Info {
137132

138133
let author_str = self.get_author_field(title);
139134

140-
write!(
141-
f,
142-
"{}{}",
143-
&self.get_formatted_subtitle_label(title),
144-
author_str.color(self.text_colors.info),
145-
)?;
135+
write!(f, "{}{}", &self.get_formatted_subtitle_label(title), author_str)?;
146136
}
147137

148138
if !self.config.disabled_fields.last_change && !self.last_change.is_empty() {
@@ -339,10 +329,12 @@ impl Info {
339329
let pad = title.len() + 2;
340330

341331
for (i, author) in self.authors.iter().enumerate() {
332+
let author_str = format!("{}", author).color(self.text_colors.info);
333+
342334
if i == 0 {
343-
author_field.push_str(&format!("{}\n", author));
335+
author_field.push_str(&format!("{}\n", author_str));
344336
} else {
345-
author_field.push_str(&format!("{:<width$}{}\n", "", author, width = pad));
337+
author_field.push_str(&format!("{:<width$}{}\n", "", author_str, width = pad));
346338
}
347339
}
348340

@@ -367,21 +359,13 @@ impl Info {
367359
};
368360

369361
for (cnt, language) in languages.iter().enumerate() {
370-
let formatted_number = format!("{:.*}", 1, language.1).color(self.text_colors.info);
362+
let formatted_number = format!("{:.*}", 1, language.1);
363+
let language_str =
364+
format!("{} ({} %) ", language.0, formatted_number).color(self.text_colors.info);
371365
if cnt != 0 && cnt % 2 == 0 {
372-
language_field.push_str(&format!(
373-
"\n{:<width$}{} ({} %) ",
374-
"",
375-
language.0.color(self.text_colors.info),
376-
formatted_number,
377-
width = pad
378-
));
366+
language_field.push_str(&format!("\n{:<width$}{}", "", language_str, width = pad));
379367
} else {
380-
language_field.push_str(&format!(
381-
"{} ({} %) ",
382-
language.0.color(self.text_colors.info),
383-
formatted_number
384-
));
368+
language_field.push_str(&format!("{}", language_str));
385369
}
386370
}
387371
language_field

0 commit comments

Comments
 (0)