diff --git a/Cargo.lock b/Cargo.lock index 3fd55ff..df3df61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -936,7 +936,6 @@ dependencies = [ "egui_extras", "git2", "json", - "lazy_static", "nu-ansi-term", "rand", "rayon", @@ -944,7 +943,6 @@ dependencies = [ "reqwest", "serde", "serde_json", - "sys-info", "sysinfo", "toml", "toml_edit", @@ -2906,16 +2904,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sys-info" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b3a0d0aba8bf96a0e1ddfdc352fc53b3df7f39318c71854910c3c4b024ae52c" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "sysinfo" version = "0.29.7" diff --git a/Cargo.toml b/Cargo.toml index a78f293..75010e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,10 +21,8 @@ rand = "0.8.5" chrono = "0.4.26" eframe = "0.22.0" trash = "3.0.3" -lazy_static = "1.4.0" rayon = "1.7.0" serde = { version = "1.0.171", features = ["derive"] } -sys-info = "0.9.1" sysinfo = "0.29.6" toml = "0.7.6" toml_edit = "0.19.14" diff --git a/src/error.rs b/src/error.rs index 07bca72..aec158e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -281,12 +281,6 @@ impl From for Error { } } -impl From for Error { - fn from(value: sys_info::Error) -> Self { - Error::MacroFailure(value.to_string()) - } -} - impl From for Error { fn from(value: SystemTimeError) -> Self { Error::MacroFailure(value.to_string()) diff --git a/src/tools/mod.rs b/src/tools/mod.rs index ae921fe..9ee5135 100644 --- a/src/tools/mod.rs +++ b/src/tools/mod.rs @@ -97,7 +97,7 @@ pub const TOOL_LIST: [&'static dyn Tool; 51] = [ &random::RandomFloat, &random::RandomInteger, &random::RandomString, - &system::CpuSpeed, + &system::Users, &logic::Assert, &logic::AssertEqual, &time::Local, diff --git a/src/tools/system.rs b/src/tools/system.rs index e77f92d..5838bb5 100644 --- a/src/tools/system.rs +++ b/src/tools/system.rs @@ -1,14 +1,14 @@ -use sys_info::cpu_speed; +use sysinfo::{RefreshKind, System, SystemExt, UserExt}; use crate::{Result, Tool, ToolInfo, Value, ValueType}; -pub struct CpuSpeed; +pub struct Users; -impl Tool for CpuSpeed { +impl Tool for Users { fn info(&self) -> ToolInfo<'static> { ToolInfo { - identifier: "cpu_speed", - description: "Return the current processor speed in megahertz.", + identifier: "users", + description: "Get a list of the system's users.", group: "system", inputs: vec![ValueType::Empty], } @@ -17,8 +17,12 @@ impl Tool for CpuSpeed { fn run(&self, argument: &Value) -> Result { argument.as_empty()?; - let speed = cpu_speed().unwrap_or_default() as i64; + let users = System::new_with_specifics(RefreshKind::new().with_users_list()) + .users() + .iter() + .map(|user| Value::String(user.name().to_string())) + .collect(); - Ok(Value::Integer(speed)) + Ok(Value::List(users)) } }