Skip to content

Commit 4c559ab

Browse files
committed
Signed-off-by: Luke-zhang-04 <[email protected]>
2 parents 6d84935 + c6908bd commit 4c559ab

File tree

6 files changed

+44
-43
lines changed

6 files changed

+44
-43
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/target
22
**/*.rs.bk
33
/stage
4-
/snap/.snapcraft
4+
/snap/snapcraft.yaml
55
*.snap
66
/parts
77
/prime

resources/bash.ascii

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
{0} ':h:'
2-
{0} ':ba:sh:,
3-
{0} ;bash, ':ba;
4-
{0} ':bash:' ':shb:'
5-
{0} ,bash; ,ash,
1+
{0} ;sh:'
2+
{0} :ba:sh:,ba;
3+
{0} ;sh, ':ba;
4+
{0} ':ba ':sh;
5+
{0} ,sh' ,ash,
66
{0} ,s:' ':h;
77
{0}'ba ,aoOk,
88
{0}:b, ;hkABASH:
99
{0}:b, ;oOBASHBASH:
1010
{0}:b, ':bBASHBASHBASH:
1111
{0}:b, ':AKBBBASHBASHBASH:
1212
{0}:b, ;okNBBB$BASHBASHBASH:
13-
{0}:b, oABASH$:$BBBBASHBASH:
14-
{0}:b, oBASH$:::$BBBASHBASH:
15-
{0}:b, oBAS$::$BASHBASHBASH:
16-
{0};b; oBASHB$::$BBBASHBASH;
17-
{0} :ba' oBAS$:::$HHBASHBASHa
18-
{0} ':sh; oBASH$:$BASHBASHBA'
13+
{0}:b, oABASH$ $BBBBASHBASH:
14+
{0}:b, oBASH$ $BBBASHBASH:
15+
{0}:b, oBAS$ $BASHBAS ASH:
16+
{0};b; oBASHB$ $BBB HBASH;
17+
{0} :ba' oBAS$ $HH SHBASHa
18+
{0} ':sh; oBASH$ $BASHBASHBA'
1919
{0} ':ba: oBASHB$BASHBAS:'
2020
{0} ;shh:, oBASHBASHBA;
2121
{0} ,:ba;o0ABN0Aa,

snap/snapcraft.yaml

-27
This file was deleted.

src/onefetch/cli.rs

+24
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use {
1010

1111
pub struct Cli {
1212
pub path: String,
13+
pub ascii_input: Option<String>,
1314
pub ascii_language: Language,
1415
pub ascii_colors: Vec<String>,
1516
pub disabled_fields: info_fields::InfoFieldOn,
@@ -74,6 +75,25 @@ impl Cli {
7475
.collect::<Vec<&str>>()
7576
),
7677
)
78+
.arg(
79+
Arg::with_name("ascii-input")
80+
.long("ascii")
81+
.value_name("STRING")
82+
.takes_value(true)
83+
.max_values(1)
84+
.help("Takes a non-empty STRING as input to replace the ASCII logo.")
85+
.long_help("Takes a non-empty STRING as input to replace the ASCII logo. \
86+
It is possible to pass a generated STRING by command substitution. \
87+
Example: onefetch --ascii \"$(fortune | cowsay -W 25)\"")
88+
.validator(
89+
|t| {
90+
if t.is_empty() {
91+
return Err(String::from("must not be empty"));
92+
}
93+
Ok(())
94+
},
95+
),
96+
)
7797
.arg(
7898
Arg::with_name("ascii-colors")
7999
.short("c")
@@ -184,6 +204,9 @@ impl Cli {
184204
};
185205

186206
let path = String::from(matches.value_of("input").unwrap());
207+
208+
let ascii_input = matches.value_of("ascii-input").map(String::from);
209+
187210
let ascii_language = if let Some(ascii_language) = matches.value_of("ascii-language") {
188211
Language::from_str(&ascii_language.to_lowercase()).unwrap()
189212
} else {
@@ -212,6 +235,7 @@ impl Cli {
212235

213236
Ok(Cli {
214237
path,
238+
ascii_input,
215239
ascii_language,
216240
ascii_colors,
217241
disabled_fields,

src/onefetch/info.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,12 @@ impl std::fmt::Display for Info {
270270
panic!("No image backend found")
271271
}
272272
} else {
273-
let mut logo_lines =
274-
AsciiArt::new(self.get_ascii(), self.colors(), !self.config.no_bold);
273+
let mut logo_lines = if let Some(custom_ascii) = &self.config.ascii_input {
274+
AsciiArt::new(custom_ascii, Vec::new(), !self.config.no_bold)
275+
} else {
276+
AsciiArt::new(self.get_ascii(), self.colors(), !self.config.no_bold)
277+
};
278+
275279
loop {
276280
match (logo_lines.next(), info_lines.next()) {
277281
(Some(logo_line), Some(info_line)) => {

src/onefetch/language.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ define_languages! {
189189
{ Forth, "forth.ascii", "Forth", define_colors!( [Color::Red] ) },
190190
{ FortranModern, "f90.ascii", "Fortran", define_colors!( [Color::White, Color::Green, Color::Cyan, Color::Yellow, Color::Red] ), "fortran" },
191191
{ FSharp, "fsharp.ascii", "F#", define_colors!( [Color::Cyan, Color::Cyan] ), "f#" },
192-
{ Go, "go.ascii", "Go", define_colors!( [Color::White] ) },
192+
{ Go, "go.ascii", "Go", define_colors!( [Color::Cyan, Color::White, Color::Yellow] : [Color::TrueColor{ r:116, g:205, b:221 }, Color::TrueColor{ r:255, g:255, b:255 }, Color::TrueColor{ r:246, g:210, b:162 }] ) },
193193
{ Groovy, "groovy.ascii", "Groovy", define_colors!( [Color::Cyan, Color::White] ) },
194194
{ Haskell, "haskell.ascii", "Haskell", define_colors!( [Color::Cyan, Color::Magenta, Color::Blue] ) },
195195
{ Html, "html.ascii", "HTML", define_colors!( [Color::Red, Color::White] ) },
@@ -251,7 +251,7 @@ define_languages! {
251251
{ Vue, "vue.ascii", "Vue", define_colors!( [Color::Green, Color::Blue] ) },
252252
{ Xml, "xml.ascii", "XML", define_colors!( [Color::Yellow, Color::White, Color::Green] ) },
253253
{ Zig, "zig.ascii", "Zig", define_colors!( [Color::Yellow] ) },
254-
{ Zsh, "zsh.ascii", "Z-shell", define_colors!( [Color::White] ), "zsh" },
254+
{ Zsh, "zsh.ascii", "Z-shell", define_colors!( [Color::White] ) },
255255
}
256256

257257
impl Language {

0 commit comments

Comments
 (0)