mirror of
https://github.com/Atsukoro1/ponyfetch.git
synced 2024-11-23 12:47:59 +01:00
feat: 🎸 Printing info
This commit is contained in:
parent
2858d3a7d8
commit
6709022e6d
7 changed files with 51 additions and 9 deletions
|
@ -1,6 +1,4 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ponyfetch"
|
name = "ponyfetch"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
|
23
src/helpers/colors.rs
Normal file
23
src/helpers/colors.rs
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1 +1,3 @@
|
||||||
pub mod file;
|
pub mod file;
|
||||||
|
pub mod colors;
|
||||||
|
pub mod print;
|
13
src/helpers/print.rs
Normal file
13
src/helpers/print.rs
Normal file
|
@ -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!();
|
||||||
|
}
|
|
@ -2,5 +2,12 @@ mod helpers;
|
||||||
mod system;
|
mod system;
|
||||||
|
|
||||||
fn main() {
|
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());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
|
use crate::helpers::file::file_open;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
use std::ops::Add;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn get_ipaddr() -> String {
|
pub fn get_ipaddr() -> String {
|
||||||
use std::ops::Add;
|
|
||||||
|
|
||||||
use crate::helpers::file::file_open;
|
|
||||||
|
|
||||||
let final_str: Mutex<String> = Mutex::new(String::new());
|
let final_str: Mutex<String> = Mutex::new(String::new());
|
||||||
let intr = file_open("/proc/net/route");
|
let intr = file_open("/proc/net/route");
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ pub fn get_cpu() -> String {
|
||||||
.collect::<Vec<&str>>()[1].to_string()
|
.collect::<Vec<&str>>()[1].to_string()
|
||||||
.replace("\t", "")
|
.replace("\t", "")
|
||||||
);
|
);
|
||||||
|
cpu = Rc::new(cpu.replacen(" ", "", 1));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue