diff --git a/Cargo.toml b/Cargo.toml index d03ef91..3024328 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,6 @@ edition = "2021" [dependencies] dotenv-parser = "0.1.3" +regex = "1.7.1" +serde = {version = "1.0.154", features = ["derive"]} +serde_json = "1.0.94" diff --git a/src/lib.rs b/src/lib.rs index 1c89dbb..b62b327 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,15 @@ use std::fs::read_to_string; - use dotenv_parser::parse_dotenv; -pub fn get_os() { +pub fn get_os() -> String { let os_release = read_to_string("/etc/os-release").unwrap(); let parsed = parse_dotenv(&os_release).unwrap(); - println!("{}", parsed.get("PRETTY_NAME").unwrap()); + parsed.get("PRETTY_NAME").unwrap().clone() +} + +pub fn get_cpu() { + let binding = std::process::Command::new("lscpu").output().expect("lscpu failed"); + let lscpu = String::from_utf8_lossy(&binding.stdout); + + println!("{}", &lscpu) } diff --git a/src/main.rs b/src/main.rs index adacdee..9a3774a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ -use gayfetch::get_os; +use gayfetch::{get_os, get_cpu}; fn main() { - get_os() + let os = get_os(); + let cpu = get_cpu(); }