@@ -166,7 +166,7 @@ impl crate::cmd::Command for CmdAuthLogin {
166166 return Ok ( ( ) ) ;
167167 }
168168 Err ( err) => {
169- return Err ( anyhow ! ( "prompt failed: {}" , err ) ) ;
169+ return Err ( anyhow ! ( "prompt failed: {err}" ) ) ;
170170 }
171171 }
172172 }
@@ -189,7 +189,7 @@ impl crate::cmd::Command for CmdAuthLogin {
189189 }
190190 }
191191 Err ( err) => {
192- return Err ( anyhow ! ( "prompt failed: {}" , err ) ) ;
192+ return Err ( anyhow ! ( "prompt failed: {err}" ) ) ;
193193 }
194194 }
195195 }
@@ -251,7 +251,7 @@ impl crate::cmd::Command for CmdAuthLogin {
251251 {
252252 Ok ( input) => input,
253253 Err ( err) => {
254- return Err ( anyhow ! ( "prompt failed: {}" , err ) ) ;
254+ return Err ( anyhow ! ( "prompt failed: {err}" ) ) ;
255255 }
256256 }
257257 } ;
@@ -274,7 +274,9 @@ impl crate::cmd::Command for CmdAuthLogin {
274274 // Save the config.
275275 ctx. config . write ( ) ?;
276276
277- writeln ! ( ctx. io. out, "{} Logged in as {}" , cs. success_icon( ) , cs. bold( & email) ) ?;
277+ let success_icon = cs. success_icon ( ) ;
278+ let bold_email = cs. bold ( & email) ;
279+ writeln ! ( ctx. io. out, "{success_icon} Logged in as {bold_email}" ) ?;
278280
279281 Ok ( ( ) )
280282 }
@@ -319,7 +321,7 @@ impl crate::cmd::Command for CmdAuthLogout {
319321 match index {
320322 Ok ( i) => candidates[ i] . to_string ( ) ,
321323 Err ( err) => {
322- return Err ( anyhow ! ( "prompt failed: {}" , err ) ) ;
324+ return Err ( anyhow ! ( "prompt failed: {err}" ) ) ;
323325 }
324326 }
325327 }
@@ -334,7 +336,7 @@ impl crate::cmd::Command for CmdAuthLogout {
334336 }
335337
336338 if !found {
337- return Err ( anyhow ! ( "not logged into {}" , hostname ) ) ;
339+ return Err ( anyhow ! ( "not logged into {hostname}" ) ) ;
338340 }
339341
340342 hostname
@@ -368,11 +370,10 @@ impl crate::cmd::Command for CmdAuthLogout {
368370 let cs = ctx. io . color_scheme ( ) ;
369371
370372 if ctx. io . can_prompt ( ) {
373+ let bold_email = cs. bold ( & email) ;
371374 match dialoguer:: Confirm :: new ( )
372375 . with_prompt ( format ! (
373- "Are you sure you want to log out of {} as {}?" ,
374- hostname,
375- cs. bold( & email)
376+ "Are you sure you want to log out of {hostname} as {bold_email}?"
376377 ) )
377378 . interact ( )
378379 {
@@ -381,7 +382,7 @@ impl crate::cmd::Command for CmdAuthLogout {
381382 return Ok ( ( ) ) ;
382383 }
383384 Err ( err) => {
384- return Err ( anyhow ! ( "prompt failed: {}" , err ) ) ;
385+ return Err ( anyhow ! ( "prompt failed: {err}" ) ) ;
385386 }
386387 }
387388 }
@@ -393,13 +394,9 @@ impl crate::cmd::Command for CmdAuthLogout {
393394 ctx. config . write ( ) ?;
394395
395396 let cs = ctx. io . color_scheme ( ) ;
396- writeln ! (
397- ctx. io. out,
398- "{} Logged out of {} as {}" ,
399- cs. success_icon( ) ,
400- hostname,
401- cs. bold( & email)
402- ) ?;
397+ let success_icon = cs. success_icon ( ) ;
398+ let bold_email = cs. bold ( & email) ;
399+ writeln ! ( ctx. io. out, "{success_icon} Logged out of {hostname} as {bold_email}" ) ?;
403400
404401 Ok ( ( ) )
405402 }
@@ -427,10 +424,10 @@ impl crate::cmd::Command for CmdAuthStatus {
427424 let hostnames = ctx. config . hosts ( ) ?;
428425
429426 if hostnames. is_empty ( ) {
427+ let bold_login = cs. bold ( "zoo auth login" ) ;
430428 writeln ! (
431429 ctx. io. out,
432- "You are not logged into any Zoo hosts. Run `{}` to authenticate." ,
433- cs. bold( "zoo auth login" )
430+ "You are not logged into any Zoo hosts. Run `{bold_login}` to authenticate."
434431 ) ?;
435432 return Ok ( ( ) ) ;
436433 }
@@ -460,21 +457,21 @@ impl crate::cmd::Command for CmdAuthStatus {
460457 . email
461458 . ok_or_else ( || anyhow:: anyhow!( "user does not have an email" ) ) ?;
462459
460+ let success_icon = cs. success_icon ( ) ;
461+ let bold_email = cs. bold ( & email) ;
463462 host_status. push ( format ! (
464- "{} Logged in to {} as {} ({})" ,
465- cs. success_icon( ) ,
466- hostname,
467- cs. bold( & email) ,
468- token_source
463+ "{success_icon} Logged in to {hostname} as {bold_email} ({token_source})"
469464 ) ) ;
470465 let mut token_display = "*******************" . to_string ( ) ;
471466 if self . show_token {
472467 token_display = token. to_string ( ) ;
473468 }
474- host_status. push ( format ! ( "{} Token: {}" , cs. success_icon( ) , token_display) ) ;
469+ let success_icon = cs. success_icon ( ) ;
470+ host_status. push ( format ! ( "{success_icon} Token: {token_display}" ) ) ;
475471 }
476472 Err ( err) => {
477- host_status. push ( format ! ( "{} {}: api call failed: {}" , cs. failure_icon( ) , hostname, err) ) ;
473+ let failure_icon = cs. failure_icon ( ) ;
474+ host_status. push ( format ! ( "{failure_icon} {hostname}: api call failed: {err}" ) ) ;
478475 failed = true ;
479476 continue ;
480477 }
@@ -484,18 +481,22 @@ impl crate::cmd::Command for CmdAuthStatus {
484481 }
485482
486483 if !hostname_found {
487- writeln ! (
488- ctx. io. err_out,
489- "Hostname {} not found among authenticated Zoo hosts" ,
490- only_host. as_deref( ) . unwrap_or( "" )
491- ) ?;
484+ if let Some ( only_host) = only_host {
485+ writeln ! (
486+ ctx. io. err_out,
487+ "Hostname {only_host} not found among authenticated Zoo hosts"
488+ ) ?;
489+ } else {
490+ writeln ! ( ctx. io. err_out, "Requested host not found among authenticated Zoo hosts" ) ?;
491+ }
492492 return Err ( anyhow ! ( "" ) ) ;
493493 }
494494
495495 for hostname in hostnames {
496496 match status_info. get ( & hostname) {
497497 Some ( status) => {
498- writeln ! ( ctx. io. out, "{}" , cs. bold( & hostname) ) ?;
498+ let bold_hostname = cs. bold ( & hostname) ;
499+ writeln ! ( ctx. io. out, "{bold_hostname}" ) ?;
499500 for line in status {
500501 writeln ! ( ctx. io. out, "{line}" ) ?;
501502 }
@@ -598,6 +599,7 @@ mod test {
598599 let mut c = crate :: config_from_env:: EnvConfig :: inherit_env ( & mut config) ;
599600
600601 for t in tests {
602+ let test_name = & t. name ;
601603 let ( mut io, stdout_path, stderr_path) = crate :: iostreams:: IoStreams :: test ( ) ;
602604 if !t. stdin . is_empty ( ) {
603605 io. stdin = Box :: new ( std:: io:: Cursor :: new ( t. stdin ) ) ;
@@ -622,19 +624,19 @@ mod test {
622624 Ok ( ( ) ) => {
623625 let stdout = std:: fs:: read_to_string ( stdout_path) . unwrap ( ) ;
624626 let stderr = std:: fs:: read_to_string ( stderr_path) . unwrap ( ) ;
625- assert ! ( stderr. is_empty( ) , "test {}: {}" , t . name , stderr ) ;
627+ assert ! ( stderr. is_empty( ) , "test {test_name }: {stderr}" ) ;
626628 if !stdout. contains ( & t. want_out ) {
627- assert_eq ! ( stdout, t. want_out, "test {}: stdout mismatch" , t . name ) ;
629+ assert_eq ! ( stdout, t. want_out, "test {test_name }: stdout mismatch" ) ;
628630 }
629631 }
630632 Err ( err) => {
631633 let stdout = std:: fs:: read_to_string ( stdout_path) . unwrap ( ) ;
632634 let stderr = std:: fs:: read_to_string ( stderr_path) . unwrap ( ) ;
633- assert_eq ! ( stdout, t. want_out, "test {}" , t . name ) ;
635+ assert_eq ! ( stdout, t. want_out, "test {test_name}" ) ;
634636 if !err. to_string ( ) . contains ( & t. want_err ) {
635- assert_eq ! ( err. to_string( ) , t. want_err, "test {}: err mismatch" , t . name ) ;
637+ assert_eq ! ( err. to_string( ) , t. want_err, "test {test_name }: err mismatch" ) ;
636638 }
637- assert ! ( stderr. is_empty( ) , "test {}: {}" , t . name , stderr ) ;
639+ assert ! ( stderr. is_empty( ) , "test {test_name }: {stderr}" ) ;
638640 }
639641 }
640642 }
0 commit comments