Skip to content

Add CLI option to disable image #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/onefetch/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct Cli {
pub excluded: Vec<String>,
pub print_languages: bool,
pub true_color: bool,
pub image_off: bool,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it's not only for images, maybe it would be better to name it art_off

}

impl Cli {
Expand Down Expand Up @@ -172,12 +173,18 @@ impl Cli {
.multiple(true)
.takes_value(true)
.help("Ignore all files & directories matching EXCLUDE."),
)
.arg(
Arg::with_name("off")
.long("off")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add .conflicts_with_all(&["image", "ascii-language", "ascii-input"])

.help("Prevents the ASCII art or image from displaying"),
).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 image_off = matches.is_present("off");
let true_color = is_truecolor_terminal();

let fields_to_hide: Vec<String> = if let Some(values) = matches.values_of("disable-fields")
Expand Down Expand Up @@ -248,6 +255,7 @@ impl Cli {
excluded,
print_languages,
true_color,
image_off,
})
}

Expand Down
6 changes: 5 additions & 1 deletion src/onefetch/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,11 @@ impl std::fmt::Display for Info {
let center_pad = " ";
let mut info_lines = buf.lines();

if let Some(custom_image) = &self.config.image {
if self.config.image_off {
while let Some(line) = info_lines.next() {
writeln!(f, "{}", line)?;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to iterate over info_lines, writeln!(f, "{}\n", buf)? should be enough

} else if let Some(custom_image) = &self.config.image {
if let Some(image_backend) = &self.config.image_backend {
writeln!(
f,
Expand Down