Skip to content
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

Add -L/--logo-only option #1468

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions docs/onefetch.1
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ If set to auto: true color will be enabled if supported by the terminal
.IP
[default: auto]
[possible values: auto, never, always]
.HP
\fB\-L\fR, \fB\-\-logo\-only\fR
.IP
Only print the ascii art without retrieving any info
.SS "IMAGE:"
.HP
\fB\-i\fR, \fB\-\-image\fR <IMAGE>
Expand Down
5 changes: 5 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use clap::builder::TypedValueParser as _;
use clap::{value_parser, Args, Command, Parser, ValueHint};
use clap_complete::{generate, Generator, Shell};
use num_format::CustomFormat;
use onefetch_ascii::AsciiArt;
use onefetch_image::ImageProtocol;
use onefetch_manifest::ManifestType;
use regex::Regex;
Expand Down Expand Up @@ -146,6 +147,9 @@ pub struct AsciiCliOptions {
/// If set to auto: true color will be enabled if supported by the terminal
#[arg(long, default_value = "auto", value_name = "WHEN", value_enum)]
pub true_color: When,
/// Only print the ascii art without retrieving any info
#[arg(long, short = 'L')]
pub logo_only: bool,
}

#[derive(Clone, Debug, Args, PartialEq, Eq)]
Expand Down Expand Up @@ -289,6 +293,7 @@ impl Default for AsciiCliOptions {
ascii_colors: Vec::default(),
ascii_language: Option::default(),
true_color: When::Auto,
logo_only: false,
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ pub fn build_info(cli_options: &CliOptions) -> Result<Info> {
let globs_to_exclude = &cli_options.info.exclude;
let show_email = cli_options.info.email;

if cli_options.ascii.logo_only {
return Ok(InfoBuilder::new(cli_options).build(cli_options, text_colors, dominant_language, ascii_colors));
}

Ok(InfoBuilder::new(cli_options)
.title(&repo, no_bold, &text_colors)
.project(&repo, &repo_url, manifest.as_ref(), number_separator)?
Expand Down
Loading