mirror of
https://github.com/Atsukoro1/ponyfetch.git
synced 2024-11-27 14:28:00 +01:00
feat: 🎸 First part working & Added some ponies
This commit is contained in:
parent
cdff610377
commit
8588a07d1a
3 changed files with 79 additions and 16 deletions
|
@ -1,17 +1,25 @@
|
|||
use crate::{helpers, system};
|
||||
use super::{file::file_open, colors::print_cyan_bold};
|
||||
use crate::helpers::{self, colors::print_bold};
|
||||
|
||||
use super::file::file_open;
|
||||
pub fn print_detail(title: &str, value: String, introduction: bool) {
|
||||
print!(" ");
|
||||
|
||||
pub fn print_detail(title: &str, value: String) {
|
||||
if introduction {
|
||||
print_bold(&format!(
|
||||
"{}@{}",
|
||||
title,
|
||||
value
|
||||
), true);
|
||||
} else {
|
||||
helpers::colors::print_cyan_bold(&title, true);
|
||||
for _ in 0..(8 - title.len()) {
|
||||
for _ in 0..(10 - title.len()) {
|
||||
print!(" ");
|
||||
}
|
||||
|
||||
helpers::colors::print_bold(" : ", true);
|
||||
|
||||
print!("{}", &value);
|
||||
println!();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_ponyline(line: u16, pony: &str) {
|
||||
|
@ -20,6 +28,6 @@ pub fn print_ponyline(line: u16, pony: &str) {
|
|||
.skip(line as usize)
|
||||
.take(1)
|
||||
.for_each(|line| {
|
||||
print!("{}", line);
|
||||
print_cyan_bold(line, true);
|
||||
});
|
||||
}
|
61
src/main.rs
61
src/main.rs
|
@ -1,9 +1,64 @@
|
|||
mod helpers;
|
||||
mod system;
|
||||
|
||||
struct Action<'a> {
|
||||
name: &'a str,
|
||||
func: fn() -> String,
|
||||
}
|
||||
|
||||
static ACTIONS: [Action; 8] = [
|
||||
Action {
|
||||
name: "Distro",
|
||||
func: system::host::get_distro,
|
||||
},
|
||||
Action {
|
||||
name: "Kernel",
|
||||
func: system::specs::get_kernel,
|
||||
},
|
||||
Action {
|
||||
name: "Uptime",
|
||||
func: system::host::get_uptime,
|
||||
},
|
||||
Action {
|
||||
name: "Shell",
|
||||
func: system::host::get_shell,
|
||||
},
|
||||
Action {
|
||||
name: "Resolution",
|
||||
func: system::host::get_resolution,
|
||||
},
|
||||
Action {
|
||||
name: "IP",
|
||||
func: system::net::get_ipaddr,
|
||||
},
|
||||
Action {
|
||||
name: "CPU",
|
||||
func: system::specs::get_cpu,
|
||||
},
|
||||
Action {
|
||||
name: "RAM",
|
||||
func: system::specs::get_ram_used,
|
||||
}
|
||||
];
|
||||
|
||||
fn main() {
|
||||
for i in 0..31 {
|
||||
helpers::print::print_ponyline(i, "celestia");
|
||||
helpers::print::print_detail("User", system::host::get_user());
|
||||
for i in 0..12 {
|
||||
helpers::print::print_ponyline(i, "rainbowdash");
|
||||
|
||||
if i == 0 {
|
||||
helpers::print::print_detail(
|
||||
&system::host::get_user(),
|
||||
system::host::get_hostname(),
|
||||
true
|
||||
);
|
||||
} else if ACTIONS.len() > (i as usize) && i != 0 {
|
||||
helpers::print::print_detail(
|
||||
ACTIONS[i as usize - 1].name,
|
||||
(ACTIONS[i as usize - 1].func)(),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
println!();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ pub fn get_distro() -> String {
|
|||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn get_uptime() -> String {
|
||||
let mut temp_buf: String = file_open("/proc/uptime");
|
||||
let temp_buf: String = file_open("/proc/uptime");
|
||||
|
||||
let uptime: u128 = temp_buf.split(".")
|
||||
.collect::<Vec<&str>>()[0]
|
||||
|
|
Loading…
Reference in a new issue