@@ -23,7 +23,7 @@ const KEE_ART: &str = r#"
2323#[ derive( Parser ) ]
2424#[ command( name = "kee" ) ]
2525#[ command( about = KEE_ART ) ]
26- #[ command( long_about = format!( "{}\n \n Examples:\n kee add myaccount Add a new AWS account\n kee use myaccount Use an account (starts sub-shell)\n kee list List all configured accounts\n kee current Show current active account\n kee remove myaccount Remove an account configuration" , KEE_ART ) ) ]
26+ #[ command( long_about = format!( "{KEE_ART }\n \n Examples:\n kee add myaccount Add a new AWS account\n kee use myaccount Use an account (starts sub-shell)\n kee list List all configured accounts\n kee current Show current active account\n kee remove myaccount Remove an account configuration" ) ) ]
2727struct Cli {
2828 #[ command( subcommand) ]
2929 command : Commands ,
@@ -66,7 +66,7 @@ struct KeeManager {
6666}
6767
6868fn hlt ( text : & str ) -> String {
69- format ! ( "{}{}{}" , BOLD_WHITE , text , RESET )
69+ format ! ( "{BOLD_WHITE}{text}{RESET}" )
7070}
7171
7272impl KeeManager {
@@ -105,7 +105,7 @@ impl KeeManager {
105105 }
106106
107107 fn add_account ( & self , account_name : & str ) -> io:: Result < bool > {
108- let profile_name = format ! ( "kee-{}" , account_name ) ;
108+ let profile_name = format ! ( "kee-{account_name}" ) ;
109109
110110 println ! ( "\n Starting SSO configuration..." ) ;
111111 println ! ( " (This will open your browser to complete authentication.)" ) ;
@@ -123,7 +123,7 @@ impl KeeManager {
123123 println ! (
124124 "\n {} When prompted for 'session name', use: {}\n " ,
125125 hlt( "Tip:" ) ,
126- hlt( & account_name)
126+ hlt( account_name)
127127 ) ;
128128
129129 // Run aws configure sso
@@ -181,7 +181,7 @@ impl KeeManager {
181181 let mut config = configparser:: ini:: Ini :: new ( ) ;
182182 config. read ( content) . ok ( ) ?;
183183
184- let section_name = format ! ( "profile {}" , profile_name ) ;
184+ let section_name = format ! ( "profile {profile_name}" ) ;
185185 let section = config. get_map_ref ( ) . get ( & section_name) ?;
186186
187187 let sso_account_id = section. get ( "sso_account_id" ) ?. as_ref ( ) ?. clone ( ) ;
@@ -200,7 +200,7 @@ impl KeeManager {
200200
201201 // Handle SSO session format - get sso_start_url and sso_region from sso-session section
202202 let ( sso_start_url, sso_region) = if !session_name. is_empty ( ) {
203- let sso_section_name = format ! ( "sso-session {}" , session_name ) ;
203+ let sso_section_name = format ! ( "sso-session {session_name}" ) ;
204204 if let Some ( sso_section) = config. get_map_ref ( ) . get ( & sso_section_name) {
205205 let start_url = sso_section
206206 . get ( "sso_start_url" )
@@ -261,7 +261,7 @@ impl KeeManager {
261261 ""
262262 } ;
263263
264- println ! ( " {}{}" , hlt( & account_name) , status) ;
264+ println ! ( " {}{}" , hlt( account_name) , status) ;
265265 println ! (
266266 " • {} {} | {} {}" ,
267267 hlt( "Account:" ) ,
@@ -278,14 +278,14 @@ impl KeeManager {
278278 let mut config = self . load_config ( ) ;
279279
280280 if !config. accounts . contains_key ( account_name) {
281- println ! ( "\n Account '{}' not found." , hlt( & account_name) ) ;
281+ println ! ( "\n Account '{}' not found." , hlt( account_name) ) ;
282282 return Ok ( false ) ;
283283 }
284284
285285 // Confirm removal
286286 print ! (
287287 "\n Are you sure you want to remove account '{}'? (y/N): " ,
288- hlt( & account_name)
288+ hlt( account_name)
289289 ) ;
290290 io:: stdout ( ) . flush ( ) ?;
291291
@@ -310,24 +310,22 @@ impl KeeManager {
310310 self . save_config ( & config) ?;
311311
312312 // Remove AWS profile and session
313- let hlt_account = hlt ( & account_name) ;
313+ let hlt_account = hlt ( account_name) ;
314314 match self . remove_aws_profile ( & account_info. profile_name ) {
315315 Ok ( _) => {
316316 if !account_info. session_name . is_empty ( ) {
317317 let _ = self . remove_sso_session ( & account_info. session_name ) ;
318318 println ! (
319- " [✓] Account '{}', AWS profile '{}', and SSO session '{}' removed." ,
320- hlt_account, hlt_account, hlt_account
319+ " [✓] Account '{hlt_account}', AWS profile '{hlt_account}', and SSO session '{hlt_account}' removed."
321320 ) ;
322321 } else {
323322 println ! (
324- " [✓] Account '{}' and AWS profile '{}' removed." ,
325- hlt_account, hlt_account
323+ " [✓] Account '{hlt_account}' and AWS profile '{hlt_account}' removed."
326324 ) ;
327325 }
328326 }
329327 Err ( e) => {
330- println ! ( " [✓] Account '{}' removed from Kee." , hlt_account ) ;
328+ println ! ( " [✓] Account '{hlt_account }' removed from Kee." ) ;
331329 println ! (
332330 " [!] {} Could not remove AWS profile '{}': {}" ,
333331 hlt( "Warning:" ) ,
@@ -359,22 +357,21 @@ impl KeeManager {
359357 }
360358
361359 let mut config = self . load_config ( ) ;
362- let hlt_account = hlt ( & account_name) ;
360+ let hlt_account = hlt ( account_name) ;
363361
364362 if !config. accounts . contains_key ( account_name) {
365- println ! ( "\n Account '{}' not found." , hlt_account ) ;
363+ println ! ( "\n Account '{hlt_account }' not found." ) ;
366364
367365 if !config. accounts . is_empty ( ) {
368366 println ! ( " Available accounts:" ) ;
369367 for name in config. accounts . keys ( ) {
370- println ! ( " • {}\n " , hlt( & name) ) ;
368+ println ! ( " • {}\n " , hlt( name) ) ;
371369 }
372370 }
373371
374372 // Offer to add the account
375373 print ! (
376- " Would you like to add account '{}' now? (y/N): " ,
377- hlt_account
374+ " Would you like to add account '{hlt_account}' now? (y/N): "
378375 ) ;
379376 io:: stdout ( ) . flush ( ) ?;
380377
@@ -384,8 +381,7 @@ impl KeeManager {
384381 if input. trim ( ) . to_lowercase ( ) == "y" {
385382 if self . add_account ( account_name) ? {
386383 print ! (
387- " Would you like to use account '{}' now? (y/N): " ,
388- hlt_account
384+ " Would you like to use account '{hlt_account}' now? (y/N): "
389385 ) ;
390386 io:: stdout ( ) . flush ( ) ?;
391387
@@ -399,12 +395,12 @@ impl KeeManager {
399395 println ! (
400396 "\n Account '{}' is ready to use. Run '{}' when needed." ,
401397 hlt_account,
402- hlt( & format!( "kee use {}" , account_name ) )
398+ hlt( & format!( "kee use {account_name}" ) )
403399 ) ;
404400 return Ok ( true ) ;
405401 }
406402 } else {
407- println ! ( " Failed to add account '{}'." , hlt_account ) ;
403+ println ! ( " Failed to add account '{hlt_account }'." ) ;
408404 return Ok ( false ) ;
409405 }
410406 } else {
@@ -484,8 +480,8 @@ impl KeeManager {
484480 } ;
485481
486482 // Show banner
487- println ! ( "{}" , KEE_ART ) ;
488- println ! ( " Session: {}" , hlt( & account_name) ) ;
483+ println ! ( "{KEE_ART}" ) ;
484+ println ! ( " Session: {}" , hlt( account_name) ) ;
489485 println ! ( "\n Starting a sub-shell for this session..." ) ;
490486 println ! ( " Type '{}' to return to your main shell." , hlt( "exit" ) ) ;
491487 println ! ( ) ;
@@ -499,15 +495,15 @@ impl KeeManager {
499495 // Update PS1 for Unix-like systems
500496 if !cfg ! ( windows) {
501497 if let Ok ( ps1) = env:: var ( "PS1" ) {
502- cmd. env ( "PS1" , format ! ( "(kee:{}) {}" , account_name , ps1 ) ) ;
498+ cmd. env ( "PS1" , format ! ( "(kee:{account_name }) {ps1}" ) ) ;
503499 } else {
504- cmd. env ( "PS1" , format ! ( "(kee:{}) $ " , account_name ) ) ;
500+ cmd. env ( "PS1" , format ! ( "(kee:{account_name }) $ " ) ) ;
505501 }
506502 }
507503
508504 let _ = cmd. status ( ) ;
509505
510- println ! ( "\n {} — Session ended." , hlt( & account_name) ) ;
506+ println ! ( "\n {} — Session ended." , hlt( account_name) ) ;
511507 Ok ( ( ) )
512508 }
513509
@@ -524,10 +520,10 @@ impl KeeManager {
524520
525521 let mut output = String :: new ( ) ;
526522 for ( section_name, section_map) in config. get_map_ref ( ) {
527- output. push_str ( & format ! ( "[{}]\n " , section_name ) ) ;
523+ output. push_str ( & format ! ( "[{section_name }]\n " ) ) ;
528524 for ( key, value_opt) in section_map {
529525 if let Some ( value) = value_opt {
530- output. push_str ( & format ! ( "{} = {}\n " , key , value ) ) ;
526+ output. push_str ( & format ! ( "{key } = {value }\n " ) ) ;
531527 }
532528 }
533529 output. push ( '\n' ) ;
@@ -547,15 +543,15 @@ impl KeeManager {
547543 . read ( content)
548544 . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: InvalidData , e) ) ?;
549545
550- let section_name = format ! ( "profile {}" , profile_name ) ;
546+ let section_name = format ! ( "profile {profile_name}" ) ;
551547 config. remove_section ( & section_name) ;
552548
553549 let mut output = String :: new ( ) ;
554550 for ( section_name, section_map) in config. get_map_ref ( ) {
555- output. push_str ( & format ! ( "[{}]\n " , section_name ) ) ;
551+ output. push_str ( & format ! ( "[{section_name }]\n " ) ) ;
556552 for ( key, value_opt) in section_map {
557553 if let Some ( value) = value_opt {
558- output. push_str ( & format ! ( "{} = {}\n " , key , value ) ) ;
554+ output. push_str ( & format ! ( "{key } = {value }\n " ) ) ;
559555 }
560556 }
561557 output. push ( '\n' ) ;
@@ -575,15 +571,15 @@ impl KeeManager {
575571 . read ( content)
576572 . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: InvalidData , e) ) ?;
577573
578- let section_name = format ! ( "sso-session {}" , session_name ) ;
574+ let section_name = format ! ( "sso-session {session_name}" ) ;
579575 config. remove_section ( & section_name) ;
580576
581577 let mut output = String :: new ( ) ;
582578 for ( section_name, section_map) in config. get_map_ref ( ) {
583- output. push_str ( & format ! ( "[{}]\n " , section_name ) ) ;
579+ output. push_str ( & format ! ( "[{section_name }]\n " ) ) ;
584580 for ( key, value_opt) in section_map {
585581 if let Some ( value) = value_opt {
586- output. push_str ( & format ! ( "{} = {}\n " , key , value ) ) ;
582+ output. push_str ( & format ! ( "{key } = {value }\n " ) ) ;
587583 }
588584 }
589585 output. push ( '\n' ) ;
0 commit comments