mirror of
https://github.com/Atsukoro1/ponyfetch.git
synced 2024-11-23 20:57:59 +01:00
feat: 🎸 Includes pony in final binary
This commit is contained in:
parent
0ca35e2ba6
commit
c50be03f3d
4 changed files with 48 additions and 17 deletions
|
@ -3,3 +3,4 @@ pub mod file;
|
||||||
pub mod colors;
|
pub mod colors;
|
||||||
pub mod print;
|
pub mod print;
|
||||||
pub mod paths;
|
pub mod paths;
|
||||||
|
pub mod ponies;
|
35
src/helpers/ponies.rs
Normal file
35
src/helpers/ponies.rs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
pub struct Pony {
|
||||||
|
pub text: String,
|
||||||
|
pub lines: u16
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_pony(name: String) -> Option<Pony> {
|
||||||
|
let ponies: HashMap<&str, Vec<u8>> = HashMap::from([
|
||||||
|
("applejack_hat_large", include_bytes!("../../ponies/applejack_hat_large.txt").to_vec()),
|
||||||
|
("applejack_hat_large", include_bytes!("../../ponies/applejack_large.txt").to_vec()),
|
||||||
|
("celestia_large", include_bytes!("../../ponies/celestia_large.txt").to_vec()),
|
||||||
|
("fluttershy_large", include_bytes!("../../ponies/fluttershy_large.txt").to_vec()),
|
||||||
|
("fluttershy", include_bytes!("../../ponies/fluttershy.txt").to_vec()),
|
||||||
|
("luna_large", include_bytes!("../../ponies/luna_large.txt").to_vec()),
|
||||||
|
("mcintosh_large", include_bytes!("../../ponies/mcintosh_large.txt").to_vec()),
|
||||||
|
("pinkiepie_large", include_bytes!("../../ponies/pinkiepie_large.txt").to_vec()),
|
||||||
|
("rainbowdash_large", include_bytes!("../../ponies/rainbowdash_large.txt").to_vec()),
|
||||||
|
("rainbowdash", include_bytes!("../../ponies/rainbowdash.txt").to_vec()),
|
||||||
|
("rarity", include_bytes!("../../ponies/rarity.txt").to_vec()),
|
||||||
|
("twilight_large", include_bytes!("../../ponies/twilight_large.txt").to_vec()),
|
||||||
|
("twilight", include_bytes!("../../ponies/twilight.txt").to_vec()),
|
||||||
|
]);
|
||||||
|
|
||||||
|
let pony = String::from_utf8(
|
||||||
|
ponies.get(
|
||||||
|
name.as_str()
|
||||||
|
).unwrap().to_vec()
|
||||||
|
).unwrap();
|
||||||
|
|
||||||
|
Some(Pony {
|
||||||
|
text: pony.clone(),
|
||||||
|
lines: pony.split("\n").count() as u16
|
||||||
|
})
|
||||||
|
}
|
|
@ -33,7 +33,6 @@ pub fn print_detail(title: &str, value: String, atype: ActionType, color: &str)
|
||||||
},
|
},
|
||||||
|
|
||||||
ActionType::Colors => {
|
ActionType::Colors => {
|
||||||
// Print the color blocks like neofetch
|
|
||||||
print("████", true, "black");
|
print("████", true, "black");
|
||||||
print("████", true, "red");
|
print("████", true, "red");
|
||||||
print("████", true, "green");
|
print("████", true, "green");
|
||||||
|
@ -45,11 +44,8 @@ pub fn print_detail(title: &str, value: String, atype: ActionType, color: &str)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_ponyline(line: u16, pony: &str, color: &str) {
|
pub fn print_ponyline(line: u16, pony: &str, color: &str) {
|
||||||
file_open(&format!("{}{}.txt", helpers::paths::get_pony_path(), pony).to_string())
|
let mut lines = pony.split("\n");
|
||||||
.lines()
|
let line = lines.nth(line as usize).unwrap().to_string();
|
||||||
.skip(line as usize)
|
|
||||||
.take(1)
|
print(&line, true, color);
|
||||||
.for_each(|line| {
|
|
||||||
print(line, true, color);
|
|
||||||
});
|
|
||||||
}
|
}
|
15
src/main.rs
15
src/main.rs
|
@ -1,4 +1,6 @@
|
||||||
use helpers::arguments::Arguments;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use helpers::{arguments::Arguments, ponies::get_pony};
|
||||||
|
|
||||||
mod helpers;
|
mod helpers;
|
||||||
mod system;
|
mod system;
|
||||||
|
@ -109,15 +111,12 @@ const ACTIONS: [Action; 13] = [
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = Arguments::parse();
|
let args = Arguments::parse();
|
||||||
|
let pony = get_pony(args.pony).unwrap();
|
||||||
|
|
||||||
let line_count = helpers::file::get_file_linecount(
|
let to_skip = ((pony.lines / 2) as f32).floor() - 6.0;
|
||||||
&format!("{}{}.txt", helpers::paths::get_pony_path(), &args.pony)
|
|
||||||
);
|
|
||||||
|
|
||||||
let to_skip = ((line_count / 2) as f32).floor() - 6.0;
|
for i in 0..pony.lines {
|
||||||
|
helpers::print::print_ponyline(i, &pony.text, &args.color);
|
||||||
for i in 0..line_count {
|
|
||||||
helpers::print::print_ponyline(i, &args.pony, &args.color);
|
|
||||||
|
|
||||||
let pad_i = (i as f32 - to_skip).floor();
|
let pad_i = (i as f32 - to_skip).floor();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue