From 9e0f431026ab764d4fef0c4a77cb18430399b08f Mon Sep 17 00:00:00 2001 From: Atsukoro1 Date: Sat, 3 Dec 2022 13:29:23 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Linux=20cpu=20arch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 2 -- src/system/specs.rs | 30 +++++++++++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7821e11..d8cc225 100644 --- a/src/main.rs +++ b/src/main.rs @@ -112,8 +112,6 @@ const ACTIONS: [Action; 13] = [ fn main() { let args: Args = Args::parse(); - println!("{}", system::specs::get_disk_usage()); - let line_count = helpers::file::get_file_linecount( &format!("{}{}.txt", helpers::paths::get_pony_path(), &args.pony) ); diff --git a/src/system/specs.rs b/src/system/specs.rs index 6937eab..a24320e 100644 --- a/src/system/specs.rs +++ b/src/system/specs.rs @@ -119,6 +119,27 @@ pub fn get_disk_usage() -> String { disk } +#[cfg(target_os = "linux")] +pub fn get_arch() -> String { + use std::process::Command; + + let mut arch = String::new(); + + let command = Command::new("lscpu") + .output() + .expect("Failed to execute process"); + + let command = String::from_utf8_lossy(&command.stdout); + + for line in command.lines() { + if line.contains("Architecture") { + arch = line.split_whitespace().last().unwrap().to_string(); + } + } + + arch +} + #[cfg(target_os = "windows")] pub fn get_arch() -> String { use std::process::Command; @@ -202,15 +223,6 @@ fn eval_ram(line: String) -> u128 { kbs / 1000 } -#[cfg(target_os = "linux")] -pub fn get_kernel() -> String { - let temp_buf: String = file_open("/proc/version"); - - temp_buf.split(" ") - .collect::>()[2] - .to_string() -} - #[cfg(target_os = "windows")] pub fn get_gpu() -> String { use std::process::Command;