Skip to content

Commit c2883d1

Browse files
committed
fix --off flag after bad merge
1 parent 522514d commit c2883d1

File tree

2 files changed

+42
-41
lines changed

2 files changed

+42
-41
lines changed

src/onefetch/cli.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl Cli {
121121
Arg::with_name("languages")
122122
.short("l")
123123
.long("languages")
124-
.help("Prints out supported languages"),
124+
.help("Prints out supported languages."),
125125
)
126126
.arg(
127127
Arg::with_name("image")
@@ -130,7 +130,7 @@ impl Cli {
130130
.value_name("IMAGE")
131131
.takes_value(true)
132132
.max_values(1)
133-
.help("Path to the IMAGE file"),
133+
.help("Path to the IMAGE file."),
134134
)
135135
.arg(
136136
Arg::with_name("image-backend")
@@ -144,12 +144,12 @@ impl Cli {
144144
.arg(
145145
Arg::with_name("no-merge-commits")
146146
.long("no-merge-commits")
147-
.help("Ignores merge commits"),
147+
.help("Ignores merge commits."),
148148
)
149149
.arg(
150150
Arg::with_name("no-color-blocks")
151151
.long("no-color-blocks")
152-
.help("Hides the color blocks"),
152+
.help("Hides the color blocks."),
153153
)
154154
.arg(
155155
Arg::with_name("authors-number")
@@ -181,7 +181,7 @@ impl Cli {
181181
.arg(
182182
Arg::with_name("off")
183183
.long("off")
184-
.help("Prevents the ASCII art or image from displaying")
184+
.help("Only shows the info lines.")
185185
.conflicts_with_all(&["image", "ascii-language", "ascii-input"]),
186186
).get_matches();
187187

src/onefetch/cli_utils.rs

+37-36
Original file line numberDiff line numberDiff line change
@@ -21,48 +21,49 @@ impl<W: Write> Printer<W> {
2121
let colors: Vec<Color> = Vec::new();
2222
let mut buf = String::new();
2323

24-
if !self.info.config.art_off {
25-
if let Some(custom_image) = &self.info.config.image {
26-
if let Some(image_backend) = &self.info.config.image_backend {
27-
buf.push_str(&image_backend.add_image(
28-
info_lines.map(|s| format!("{}{}", center_pad, s)).collect(),
29-
custom_image,
30-
));
31-
} else {
32-
panic!("No image backend found")
33-
}
24+
if self.info.config.art_off {
25+
buf.push_str(&info_str);
26+
} else if let Some(custom_image) = &self.info.config.image {
27+
if let Some(image_backend) = &self.info.config.image_backend {
28+
buf.push_str(&image_backend.add_image(
29+
info_lines.map(|s| format!("{}{}", center_pad, s)).collect(),
30+
custom_image,
31+
));
32+
} else {
33+
panic!("No image backend found")
34+
}
35+
} else {
36+
let mut logo_lines = if let Some(custom_ascii) = &self.info.config.ascii_input {
37+
AsciiArt::new(custom_ascii, &colors, !self.info.config.no_bold)
3438
} else {
35-
let mut logo_lines = if let Some(custom_ascii) = &self.info.config.ascii_input {
36-
AsciiArt::new(custom_ascii, &colors, !self.info.config.no_bold)
37-
} else {
38-
AsciiArt::new(
39-
self.get_ascii(),
40-
&self.info.colors,
41-
!self.info.config.no_bold,
42-
)
43-
};
39+
AsciiArt::new(
40+
self.get_ascii(),
41+
&self.info.colors,
42+
!self.info.config.no_bold,
43+
)
44+
};
4445

45-
loop {
46-
match (logo_lines.next(), info_lines.next()) {
47-
(Some(logo_line), Some(info_line)) => {
48-
buf.push_str(&format!("{}{}{:^}\n", logo_line, center_pad, info_line))
49-
}
50-
(Some(logo_line), None) => buf.push_str(&format!("{}\n", logo_line)),
51-
(None, Some(info_line)) => buf.push_str(&format!(
52-
"{:<width$}{}{:^}\n",
53-
"",
54-
center_pad,
55-
info_line,
56-
width = logo_lines.width()
57-
)),
58-
(None, None) => {
59-
buf.push('\n');
60-
break;
61-
}
46+
loop {
47+
match (logo_lines.next(), info_lines.next()) {
48+
(Some(logo_line), Some(info_line)) => {
49+
buf.push_str(&format!("{}{}{:^}\n", logo_line, center_pad, info_line))
50+
}
51+
(Some(logo_line), None) => buf.push_str(&format!("{}\n", logo_line)),
52+
(None, Some(info_line)) => buf.push_str(&format!(
53+
"{:<width$}{}{:^}\n",
54+
"",
55+
center_pad,
56+
info_line,
57+
width = logo_lines.width()
58+
)),
59+
(None, None) => {
60+
buf.push('\n');
61+
break;
6262
}
6363
}
6464
}
6565
}
66+
6667
writeln!(self.writer, "{}", buf)?;
6768

6869
Ok(())

0 commit comments

Comments
 (0)