diff --git a/Cargo.toml b/Cargo.toml index 4a4ab0b..e2382f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,4 @@ [package] name = "ponyfetch" version = "0.1.0" -edition = "2021" - -[dependencies] \ No newline at end of file +edition = "2021" \ No newline at end of file diff --git a/src/helpers/colors.rs b/src/helpers/colors.rs new file mode 100644 index 0000000..6f45bfb --- /dev/null +++ b/src/helpers/colors.rs @@ -0,0 +1,23 @@ +pub fn print_cyan(text: &str, inline: bool) { + if inline { + print!("\x1b[36m{}\x1b[0m", text); + } else { + println!("\x1b[36m{}\x1b[0m", text); + } +} + +pub fn print_cyan_bold(text: &str, inline: bool) { + if inline { + print!("\x1b[36m\x1b[1m{}\x1b[0m", text); + } else { + println!("\x1b[36m\x1b[1m{}\x1b[0m", text); + } +} + +pub fn print_bold(text: &str, inline: bool) { + if inline { + print!("\x1b[1m{}\x1b[0m", text); + } else { + println!("\x1b[1m{}\x1b[0m", text); + } +} \ No newline at end of file diff --git a/src/helpers/mod.rs b/src/helpers/mod.rs index e0d1abe..dc90cec 100644 --- a/src/helpers/mod.rs +++ b/src/helpers/mod.rs @@ -1 +1,3 @@ -pub mod file; \ No newline at end of file +pub mod file; +pub mod colors; +pub mod print; \ No newline at end of file diff --git a/src/helpers/print.rs b/src/helpers/print.rs new file mode 100644 index 0000000..4ce238d --- /dev/null +++ b/src/helpers/print.rs @@ -0,0 +1,13 @@ +use crate::{helpers, system}; + +pub fn print_detail(title: &str, value: String) { + helpers::colors::print_cyan_bold(&title, true); + for _ in 0..(8 - title.len()) { + print!(" "); + } + + helpers::colors::print_bold(" : ", true); + + print!("{}", &value); + println!(); +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 7e97b1d..d8dfd7d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,5 +2,12 @@ mod helpers; mod system; fn main() { - println!("{}", system::specs::get_kernel()); + helpers::print::print_detail("User", system::host::get_user()); + helpers::print::print_detail("Hostname", system::host::get_hostname()); + helpers::print::print_detail("IP", system::net::get_ipaddr()); + helpers::print::print_detail("Kernel", system::specs::get_kernel()); + helpers::print::print_detail("RAM", system::specs::get_ram_used()); + helpers::print::print_detail("CPU", system::specs::get_cpu()); + helpers::print::print_detail("Distro", system::host::get_distro()); + helpers::print::print_detail("Shell", system::host::get_shell()); } diff --git a/src/system/net.rs b/src/system/net.rs index 8a4b251..06e5a20 100644 --- a/src/system/net.rs +++ b/src/system/net.rs @@ -1,12 +1,10 @@ +use crate::helpers::file::file_open; use std::process::Command; use std::sync::Mutex; +use std::ops::Add; #[cfg(target_os = "linux")] pub fn get_ipaddr() -> String { - use std::ops::Add; - - use crate::helpers::file::file_open; - let final_str: Mutex = Mutex::new(String::new()); let intr = file_open("/proc/net/route"); diff --git a/src/system/specs.rs b/src/system/specs.rs index 6e8eff8..3bcd62b 100644 --- a/src/system/specs.rs +++ b/src/system/specs.rs @@ -20,6 +20,7 @@ pub fn get_cpu() -> String { .collect::>()[1].to_string() .replace("\t", "") ); + cpu = Rc::new(cpu.replacen(" ", "", 1)); } });