Skip to content

Commit

Permalink
Add ascii flag
Browse files Browse the repository at this point in the history
  • Loading branch information
KaindlJulian committed Oct 20, 2020
1 parent b7d51f3 commit 2e48d98
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/onefetch/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use {

pub struct Cli {
pub path: String,
pub ascii_input: Option<String>,
pub ascii_language: Language,
pub ascii_colors: Vec<String>,
pub disabled_fields: info_fields::InfoFieldOn,
Expand Down Expand Up @@ -73,6 +74,13 @@ impl Cli {
.collect::<Vec<&str>>()
),
)
.arg(
Arg::with_name("ascii-input")
.long("ascii")
.value_name("STRING")
.takes_value(true)
.help("Takes a STRING as input to replace the ASCII logo")
)
.arg(
Arg::with_name("ascii-colors")
.short("c")
Expand Down Expand Up @@ -182,6 +190,9 @@ impl Cli {
};

let path = String::from(matches.value_of("input").unwrap());

let ascii_input = matches.value_of("ascii-input").map(String::from);

let ascii_language = if let Some(ascii_language) = matches.value_of("ascii-language") {
Language::from_str(&ascii_language.to_lowercase()).unwrap()
} else {
Expand Down Expand Up @@ -210,6 +221,7 @@ impl Cli {

Ok(Cli {
path,
ascii_input,
ascii_language,
ascii_colors,
disabled_fields,
Expand Down
5 changes: 5 additions & 0 deletions src/onefetch/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ impl std::fmt::Display for Info {
} else {
let mut logo_lines =
AsciiArt::new(self.get_ascii(), self.colors(), !self.config.no_bold);

if let Some(custom_ascii) = &self.config.ascii_input {
logo_lines = AsciiArt::new(custom_ascii, Vec::new(), !self.config.no_bold);
}

loop {
match (logo_lines.next(), info_lines.next()) {
(Some(logo_line), Some(info_line)) => {
Expand Down

0 comments on commit 2e48d98

Please sign in to comment.