mirror of
https://github.com/Atsukoro1/ponyfetch.git
synced 2024-11-23 12:47:59 +01:00
feat: 🎸 Ponies embedded in binary instead of fs
This commit is contained in:
parent
c50be03f3d
commit
a6e62eda7f
6 changed files with 20 additions and 76 deletions
|
@ -7,13 +7,4 @@ pub fn file_open(path: &str) -> String {
|
|||
file.read_to_string(&mut temp_buf).unwrap();
|
||||
|
||||
temp_buf
|
||||
}
|
||||
|
||||
pub fn get_file_linecount(path: &str) -> u16 {
|
||||
let mut temp_buf: String = String::new();
|
||||
|
||||
let mut file = File::open(path).unwrap();
|
||||
file.read_to_string(&mut temp_buf).unwrap();
|
||||
|
||||
temp_buf.lines().count() as u16
|
||||
}
|
|
@ -1,45 +1,17 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
pub fn get_ponies() -> Vec<String> {
|
||||
let mut ponies: Vec<String> = Vec::new();
|
||||
let pony_files = std::fs::read_dir(get_pony_path()).unwrap();
|
||||
|
||||
pony_files.for_each(|file| {
|
||||
let file = file.unwrap();
|
||||
let file_name = file.file_name().into_string().unwrap();
|
||||
let file_name = file_name.split(".").collect::<Vec<&str>>()[0].to_string();
|
||||
ponies.push(file_name);
|
||||
});
|
||||
|
||||
ponies
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn get_pony_path() -> String {
|
||||
if std::env::current_exe().unwrap().to_str().unwrap().contains("target") {
|
||||
PathBuf::from("ponies/")
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_string()
|
||||
} else {
|
||||
PathBuf::from("/usr/share/ponyfetch/ponies/")
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn get_pony_path() -> String {
|
||||
if std::env::current_exe().unwrap().to_str().unwrap().contains("target") {
|
||||
PathBuf::from("ponies/")
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_string()
|
||||
} else {
|
||||
PathBuf::from("C:\\Program Files\\Ponyfetch\\ponies\\")
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_string()
|
||||
}
|
||||
pub fn get_ponies() -> Vec<&'static str> {
|
||||
vec![
|
||||
"applejack_hat_large",
|
||||
"applejack_large",
|
||||
"celestia_large",
|
||||
"fluttershy_large",
|
||||
"fluttershy",
|
||||
"luna_large",
|
||||
"mcintosh_large",
|
||||
"pinkiepie_large",
|
||||
"rainbowdash_large",
|
||||
"rainbowdash",
|
||||
"rarity",
|
||||
"twilight_large",
|
||||
"twilight",
|
||||
]
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
pub struct Pony {
|
||||
pub text: String,
|
||||
pub lines: u16
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use super::{file::file_open, colors::print};
|
||||
use super::colors::print;
|
||||
use crate::{helpers::{self}, ActionType};
|
||||
|
||||
pub fn print_detail(title: &str, value: String, atype: ActionType, color: &str) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use helpers::{arguments::Arguments, ponies::get_pony};
|
||||
use helpers::arguments::Arguments;
|
||||
use helpers::ponies::get_pony;
|
||||
|
||||
mod helpers;
|
||||
mod system;
|
||||
|
@ -143,7 +142,7 @@ fn main() {
|
|||
args.color.as_str()
|
||||
);
|
||||
},
|
||||
|
||||
|
||||
ActionType::Details => {
|
||||
helpers::print::print_detail(
|
||||
ACTIONS[pad_i as usize].name.unwrap(),
|
||||
|
|
|
@ -174,23 +174,6 @@ pub fn get_distro() -> String {
|
|||
distro.to_string()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn get_uptime() -> String {
|
||||
let temp_buf: String = file_open("/proc/uptime");
|
||||
|
||||
let uptime: u128 = temp_buf.split(".")
|
||||
.collect::<Vec<&str>>()[0]
|
||||
.parse()
|
||||
.unwrap();
|
||||
|
||||
let days = uptime / 86400;
|
||||
let hours = (uptime % 86400) / 3600;
|
||||
let minutes = (uptime % 3600) / 60;
|
||||
let seconds = uptime % 60;
|
||||
|
||||
format!("{}d {}h {}m {}s", days, hours, minutes, seconds)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn get_shell() -> String {
|
||||
let temp_buf: String = file_open("/etc/passwd");
|
||||
|
|
Loading…
Reference in a new issue