diff --git a/.gitignore b/.gitignore index 22d3516..11c9c89 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ Cargo.lock # Added by cargo /target +/.idea \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..463742f --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,6 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +.idea diff --git a/Cargo.toml b/Cargo.toml index 3812721..d52f277 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ publish = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -colored = "2.0.0" -whoami = "1.1.1" -sysinfo = { version = "0.23.2", default-features = false } +colored = "2.1.0" +whoami = "1.5.1" +sysinfo = { version = "0.30.12", default-features = false } +humansize = "2.1.3" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 93ab3d9..3098c67 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,8 @@ use colored::*; use std::string::ToString; -use sysinfo::{System, SystemExt, RefreshKind, ProcessorExt}; +use sysinfo::{System, RefreshKind, CpuRefreshKind}; +use whoami::fallible; +use humansize::{make_format, DECIMAL}; const FERRIS_ART: &[&str] = &[ " ", @@ -50,7 +52,7 @@ fn get_cargo_crates() -> usize { fn render(art: bool, info: &[String]) { if art { for (ferris_line, info_line) in FERRIS_ART.iter().zip(info) { - println!("{} {}", ferris_line.red(), info_line); + println!("{} {}", ferris_line.bright_red(), info_line); } } else { for line in info { @@ -66,38 +68,43 @@ fn main() { art = false; } - let mut sys = System::new_with_specifics(RefreshKind::new().with_cpu()); + let mut sys = System::new_with_specifics(RefreshKind::new().with_cpu(CpuRefreshKind::everything())); sys.refresh_all(); - let kernel = sys.kernel_version().unwrap_or_else(|| "Unknown".into()); + let kernel = System::kernel_version().unwrap_or_else(|| "Unknown".into()); let total_ram = sys.total_memory(); let used_ram = sys.used_memory(); - let cpu = sys.processors()[0].brand(); + let cpu = sys.cpus()[0].brand(); let rustc_ver = get_ver("rustc -V"); let cargo_ver = get_ver("cargo -V"); let rustup_ver = get_ver("rustup -V"); let cargo_crates = get_cargo_crates(); + let username = fallible::username().unwrap_or("unknown".to_string()); + let hostname = fallible::hostname().unwrap_or("unknown".to_string()); + let userinfo = format!( "{}{}{}", - whoami::username().bright_red().bold(), + username.bright_red().bold(), "@".bold(), - whoami::hostname().bright_red().bold() + hostname.bright_red().bold() ); - let splitline = "═".repeat(whoami::username().len() + whoami::hostname().len() + 1); - let rustc_ver = format!("{}{}", "rustc ver: ".bright_red(), rustc_ver); - let rustup_ver = format!("{}{}", "rustup ver: ".bright_red(), rustup_ver); - let cargo_ver = format!("{}{}", "cargo ver: ".bright_red(), cargo_ver); - let cargo_crates = format!("{}{}", "cargo crates: ".bright_red(), cargo_crates); - let os = format!("{}{}", "os: ".bright_red(), whoami::distro()); - let kernel = format!("{}{}", "kernel: ".bright_red(), kernel); - let cpu = format!("{}{}", "cpu: ".bright_red(), cpu); + let splitline = "═".repeat(username.len() + hostname.len() + 1); + let rustc_ver = format!("{}{}", " rustc: ".bright_red(), rustc_ver); + let rustup_ver = format!("{}{}", " rustup: ".bright_red(), rustup_ver); + let cargo_ver = format!("{}{}", " cargo: ".bright_red(), cargo_ver); + let cargo_crates = format!("{}{}", " crates: ".bright_red(), cargo_crates); + let os = format!("{}{}", " os: ".bright_red(), whoami::distro()); + let kernel = format!("{}{}", " kernel: ".bright_red(), kernel); + let cpu = format!("{}{}", " cpu: ".bright_red(), cpu); + + let formatter = make_format(DECIMAL); + let ram = format!( - "{}{} » {}{}", - "ram: ".bright_red(), - used_ram, - total_ram, - " MB" + "{}{} » {}", + " ram: ".bright_red(), + formatter(used_ram), + formatter(total_ram) ); let bright_colors = format!( @@ -126,7 +133,6 @@ fn main() { render( art, &[ - "".to_string(), "".to_string(), userinfo, splitline,