Fixed dependency on Unix-only library for username/hostname.

This commit is contained in:
Shibe Drill 2023-01-04 14:53:03 -05:00
parent 9d93a8849d
commit e77e611e2d
3 changed files with 25 additions and 17 deletions

32
Cargo.lock generated
View File

@ -238,7 +238,7 @@ dependencies = [
"quoted-string",
"sys-info",
"time 0.3.17",
"users",
"whoami",
]
[[package]]
@ -346,16 +346,6 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
[[package]]
name = "users"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24cc0f6d6f267b73e5a2cadf007ba8f9bc39c6a6f9666f8cf25ea809a153b032"
dependencies = [
"libc",
"log",
]
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
@ -416,6 +406,26 @@ version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
[[package]]
name = "web-sys"
version = "0.3.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "whoami"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45dbc71f0cdca27dc261a9bd37ddec174e4a0af2b900b890f378460f745426e3"
dependencies = [
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "winapi"
version = "0.3.9"

View File

@ -11,4 +11,5 @@ colored = "2.0.0"
quoted-string = "0.6.1"
sys-info = "0.9.1"
time = "0.3.17"
users = "0.11.0"
#users = "0.11.0"
whoami = "1.3.0"

View File

@ -1,6 +1,6 @@
use colored::*;
use sys_info::*;
use users::*;
use whoami::*;
use chrono::*;
fn get_os() -> OsInfo {
@ -82,10 +82,7 @@ fn main() {
let current_info = get_os();
let info_string = format!("{} {}", current_info.icon, current_info.name).color(current_info.term_color).bold();
if hostname().is_ok() & get_current_username().is_some() {
let username = format!("{:#?}", get_current_username().unwrap());
println!("{} {}", String::from("Host:").bright_white(), format!("{}@{}", &username[1..(username.len() - 1)], hostname().unwrap()).bold())
}
println!("{} {}", String::from("Host:").bright_white(), format!("{}@{}", username(), whoami::hostname()).bold());
println!("{} {}", String::from("OS:").bright_white(), info_string);
if proc_total().is_ok() {