diff --git a/src/uu/whoami/src/whoami.rs b/src/uu/whoami/src/whoami.rs index cb8bcd9c7..738f7509a 100644 --- a/src/uu/whoami/src/whoami.rs +++ b/src/uu/whoami/src/whoami.rs @@ -5,6 +5,8 @@ /* last synced with: whoami (GNU coreutils) 8.21 */ +use std::ffi::OsString; + use clap::{crate_version, Command}; use uucore::display::println_verbatim; @@ -19,11 +21,16 @@ const USAGE: &str = help_usage!("whoami.md"); #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { uu_app().try_get_matches_from(args)?; - let username = platform::get_username().map_err_context(|| "failed to get username".into())?; + let username = whoami()?; println_verbatim(username).map_err_context(|| "failed to print username".into())?; Ok(()) } +/// Get the current username +pub fn whoami() -> UResult { + platform::get_username().map_err_context(|| "failed to get username".into()) +} + pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(crate_version!())