diff --git a/src/onefetch/cli.rs b/src/onefetch/cli.rs index 2b9a5613d..c4da73b5d 100644 --- a/src/onefetch/cli.rs +++ b/src/onefetch/cli.rs @@ -27,6 +27,7 @@ pub struct Cli { pub excluded: Vec, pub print_languages: bool, pub true_color: bool, + pub art_off: bool, } impl Cli { @@ -176,12 +177,19 @@ impl Cli { .multiple(true) .takes_value(true) .help("Ignore all files & directories matching EXCLUDE."), + ) + .arg( + Arg::with_name("off") + .long("off") + .help("Prevents the ASCII art or image from displaying") + .conflicts_with_all(&["image", "ascii-language", "ascii-input"]), ).get_matches(); let no_bold = matches.is_present("no-bold"); let no_merges = matches.is_present("no-merge-commits"); let no_color_blocks = matches.is_present("no-color-blocks"); let print_languages = matches.is_present("languages"); + let art_off = matches.is_present("off"); let true_color = cli_utils::is_truecolor_terminal(); let fields_to_hide: Vec = if let Some(values) = matches.values_of("disable-fields") @@ -252,6 +260,7 @@ impl Cli { excluded, print_languages, true_color, + art_off, }) } } diff --git a/src/onefetch/cli_utils.rs b/src/onefetch/cli_utils.rs index 9bfff27e7..2751bdc7b 100644 --- a/src/onefetch/cli_utils.rs +++ b/src/onefetch/cli_utils.rs @@ -20,47 +20,49 @@ impl Printer { let mut info_lines = info_str.lines(); let colors: Vec = Vec::new(); let mut buf = String::new(); - if let Some(custom_image) = &self.info.config.image { - if let Some(image_backend) = &self.info.config.image_backend { - buf.push_str(&image_backend.add_image( - info_lines.map(|s| format!("{}{}", center_pad, s)).collect(), - custom_image, - )); - } else { - panic!("No image backend found") - } - } else { - let mut logo_lines = if let Some(custom_ascii) = &self.info.config.ascii_input { - AsciiArt::new(custom_ascii, &colors, !self.info.config.no_bold) + + if !self.info.config.art_off { + if let Some(custom_image) = &self.info.config.image { + if let Some(image_backend) = &self.info.config.image_backend { + buf.push_str(&image_backend.add_image( + info_lines.map(|s| format!("{}{}", center_pad, s)).collect(), + custom_image, + )); + } else { + panic!("No image backend found") + } } else { - AsciiArt::new( - self.get_ascii(), - &self.info.colors, - !self.info.config.no_bold, - ) - }; + let mut logo_lines = if let Some(custom_ascii) = &self.info.config.ascii_input { + AsciiArt::new(custom_ascii, &colors, !self.info.config.no_bold) + } else { + AsciiArt::new( + self.get_ascii(), + &self.info.colors, + !self.info.config.no_bold, + ) + }; - loop { - match (logo_lines.next(), info_lines.next()) { - (Some(logo_line), Some(info_line)) => { - buf.push_str(&format!("{}{}{:^}\n", logo_line, center_pad, info_line)) - } - (Some(logo_line), None) => buf.push_str(&format!("{}\n", logo_line)), - (None, Some(info_line)) => buf.push_str(&format!( - "{: { - buf.push('\n'); - break; + loop { + match (logo_lines.next(), info_lines.next()) { + (Some(logo_line), Some(info_line)) => { + buf.push_str(&format!("{}{}{:^}\n", logo_line, center_pad, info_line)) + } + (Some(logo_line), None) => buf.push_str(&format!("{}\n", logo_line)), + (None, Some(info_line)) => buf.push_str(&format!( + "{: { + buf.push('\n'); + break; + } } } } } - writeln!(self.writer, "{}", buf)?; Ok(())