mirror of
https://github.com/Atsukoro1/ponyfetch.git
synced 2024-11-27 14:28:00 +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
|
@ -8,12 +8,3 @@ pub fn file_open(path: &str) -> String {
|
||||||
|
|
||||||
temp_buf
|
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<&'static str> {
|
||||||
|
vec![
|
||||||
pub fn get_ponies() -> Vec<String> {
|
"applejack_hat_large",
|
||||||
let mut ponies: Vec<String> = Vec::new();
|
"applejack_large",
|
||||||
let pony_files = std::fs::read_dir(get_pony_path()).unwrap();
|
"celestia_large",
|
||||||
|
"fluttershy_large",
|
||||||
pony_files.for_each(|file| {
|
"fluttershy",
|
||||||
let file = file.unwrap();
|
"luna_large",
|
||||||
let file_name = file.file_name().into_string().unwrap();
|
"mcintosh_large",
|
||||||
let file_name = file_name.split(".").collect::<Vec<&str>>()[0].to_string();
|
"pinkiepie_large",
|
||||||
ponies.push(file_name);
|
"rainbowdash_large",
|
||||||
});
|
"rainbowdash",
|
||||||
|
"rarity",
|
||||||
ponies
|
"twilight_large",
|
||||||
}
|
"twilight",
|
||||||
|
]
|
||||||
#[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()
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub struct Pony {
|
pub struct Pony {
|
||||||
pub text: String,
|
pub text: String,
|
||||||
pub lines: u16
|
pub lines: u16
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{file::file_open, colors::print};
|
use super::colors::print;
|
||||||
use crate::{helpers::{self}, ActionType};
|
use crate::{helpers::{self}, ActionType};
|
||||||
|
|
||||||
pub fn print_detail(title: &str, value: String, atype: ActionType, color: &str) {
|
pub fn print_detail(title: &str, value: String, atype: ActionType, color: &str) {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use std::collections::HashMap;
|
use helpers::arguments::Arguments;
|
||||||
|
use helpers::ponies::get_pony;
|
||||||
use helpers::{arguments::Arguments, ponies::get_pony};
|
|
||||||
|
|
||||||
mod helpers;
|
mod helpers;
|
||||||
mod system;
|
mod system;
|
||||||
|
|
|
@ -174,23 +174,6 @@ pub fn get_distro() -> String {
|
||||||
distro.to_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")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn get_shell() -> String {
|
pub fn get_shell() -> String {
|
||||||
let temp_buf: String = file_open("/etc/passwd");
|
let temp_buf: String = file_open("/etc/passwd");
|
||||||
|
|
Loading…
Reference in a new issue