Retrieve the current user and environment.
Using the whoami crate is super easy! All of the exported items are simple functions with no parameters that return either a String
or enum. The following example shows how to use all of the functions:
rust
fn main() {
print!(
"--------------------------------------------------------------------------------\n\
user's full name (user): {}\n\
username (username): {}\n\
--------------------------------------------------------------------------------\n\
host's fancy name (host): {}\n\
hostname (hostname): {}\n\
--------------------------------------------------------------------------------\n\
platform (platform): {}\n\
operating system (os): {}\n\
desktop environment (env): {}\n\
--------------------------------------------------------------------------------\n\
",
whoami::user(),
whoami::username(),
whoami::host(),
whoami::hostname(),
whoami::platform(),
whoami::os(),
whoami::env(),
);
}
whome: replacement of the whoami
command that depends on this crate.