@@ -13,6 +13,7 @@ pub struct Environment {
1313
1414
1515impl Environment {
16+ /// Gather information on the environment floki is running in
1617 pub fn gather ( ) -> Result < Self , Error > {
1718 Ok ( Environment {
1819 user_details : get_user_details ( ) ?,
@@ -23,12 +24,14 @@ impl Environment {
2324}
2425
2526
27+ /// Run a command and extract stdout as a String
2628fn run_and_get_raw_output ( cmd : & mut Command ) -> Result < String , Error > {
2729 let output = String :: from_utf8 ( cmd. output ( ) ?. stdout ) ?;
2830 Ok ( output. trim_end ( ) . into ( ) )
2931}
3032
31- pub fn get_user_details ( ) -> Result < ( String , String ) , Error > {
33+ /// Get the user and group ids of the current user
34+ fn get_user_details ( ) -> Result < ( String , String ) , Error > {
3235 let user = run_and_get_raw_output ( Command :: new ( "id" ) . arg ( "-u" ) ) ?;
3336 debug ! ( "User's current id: {:?}" , user) ;
3437 let group = run_and_get_raw_output ( Command :: new ( "id" ) . arg ( "-g" ) ) ?;
@@ -38,7 +41,7 @@ pub fn get_user_details() -> Result<(String, String), Error> {
3841
3942/// Get the current working directory as a String
4043fn get_current_working_directory ( ) -> Result < String , Error > {
41- Ok ( format ! ( "{}" , env:: current_dir( ) ?. display( ) ) )
44+ Ok ( env:: current_dir ( ) ?. display ( ) . to_string ( ) )
4245}
4346
4447
0 commit comments