@@ -37,7 +37,10 @@ pub async fn execute(
3737 Ok ( _) => return Ok ( ( ) ) , // Exact match found and connected
3838 Err ( _) => {
3939 // No exact match, try fuzzy search
40- info ! ( "No exact match found for '{}', attempting fuzzy search" , target) ;
40+ info ! (
41+ "No exact match found for '{}', attempting fuzzy search" ,
42+ target
43+ ) ;
4144 }
4245 }
4346
@@ -53,14 +56,27 @@ pub async fn execute(
5356 if !recent. is_empty ( ) {
5457 println ! ( "\n 📅 Recent connections:" ) ;
5558 for ( i, conn) in recent. iter ( ) . enumerate ( ) {
56- let last_used = conn. last_used
59+ let last_used = conn
60+ . last_used
5761 . map ( |dt| format ! ( " (last used: {})" , format_duration( dt) ) )
58- . unwrap_or_else ( || "" . to_string ( ) ) ;
62+ . unwrap_or_default ( ) ;
5963 println ! ( " {}. {}{}" , i + 1 , conn. name, last_used) ;
6064 }
6165
62- if let Some ( selection) = interactive_selection ( & recent, "Select recent connection" ) ? {
63- return ssh_service. connect_to_connection ( & selection, user, port, kerberos, bastion, no_bastion, bastion_user, key) . await ;
66+ if let Some ( selection) = interactive_selection ( & recent, "Select recent connection" ) ?
67+ {
68+ return ssh_service
69+ . connect_to_connection (
70+ & selection,
71+ user,
72+ port,
73+ kerberos,
74+ bastion,
75+ no_bastion,
76+ bastion_user,
77+ key,
78+ )
79+ . await ;
6480 }
6581 } else {
6682 println ! ( "No recent connections found." ) ;
@@ -81,23 +97,49 @@ pub async fn execute(
8197 let input = input. trim ( ) . to_lowercase ( ) ;
8298
8399 if matches ! ( input. as_str( ) , "y" | "yes" ) {
84- return ssh_service. connect_to_connection ( conn, user, port, kerberos, bastion, no_bastion, bastion_user, key) . await ;
100+ return ssh_service
101+ . connect_to_connection (
102+ conn,
103+ user,
104+ port,
105+ kerberos,
106+ bastion,
107+ no_bastion,
108+ bastion_user,
109+ key,
110+ )
111+ . await ;
85112 } else {
86113 println ! ( "Connection cancelled." ) ;
87114 return Ok ( ( ) ) ;
88115 }
89116 }
90117 _ => {
91118 // Multiple matches - interactive selection
92- println ! ( "🔍 Found {} similar connections for '{}':" , matches. len( ) , target) ;
119+ println ! (
120+ "🔍 Found {} similar connections for '{}':" ,
121+ matches. len( ) ,
122+ target
123+ ) ;
93124 println ! ( ) ;
94125
95126 for ( i, conn) in matches. iter ( ) . enumerate ( ) {
96127 print_connection_info ( conn, i + 1 ) ;
97128 }
98129
99130 if let Some ( selection) = interactive_selection ( & matches, "Select connection" ) ? {
100- return ssh_service. connect_to_connection ( & selection, user, port, kerberos, bastion, no_bastion, bastion_user, key) . await ;
131+ return ssh_service
132+ . connect_to_connection (
133+ & selection,
134+ user,
135+ port,
136+ kerberos,
137+ bastion,
138+ no_bastion,
139+ bastion_user,
140+ key,
141+ )
142+ . await ;
101143 }
102144 }
103145 }
@@ -112,12 +154,21 @@ fn print_connection_info(connection: &crate::models::Connection, index: usize) {
112154 format ! ( " [{}]" , connection. tags. join( ", " ) )
113155 } ;
114156
115- let last_used = connection. last_used
157+ let last_used = connection
158+ . last_used
116159 . map ( |dt| format ! ( " (last used: {})" , format_duration( dt) ) )
117- . unwrap_or_else ( || "" . to_string ( ) ) ;
160+ . unwrap_or_default ( ) ;
118161
119162 println ! ( " {}. {} ({})" , index, connection. name, connection. host) ;
120- println ! ( " Tags: {}{}" , if tags_str. is_empty( ) { "none" } else { & tags_str[ 1 ..tags_str. len( ) -1 ] } , last_used) ;
163+ println ! (
164+ " Tags: {}{}" ,
165+ if tags_str. is_empty( ) {
166+ "none"
167+ } else {
168+ & tags_str[ 1 ..tags_str. len( ) - 1 ]
169+ } ,
170+ last_used
171+ ) ;
121172 println ! ( ) ;
122173}
123174
@@ -148,9 +199,16 @@ fn format_duration(dt: chrono::DateTime<chrono::Utc>) -> String {
148199 }
149200}
150201
151- fn interactive_selection ( connections : & [ crate :: models:: Connection ] , prompt : & str ) -> Result < Option < crate :: models:: Connection > > {
202+ fn interactive_selection (
203+ connections : & [ crate :: models:: Connection ] ,
204+ prompt : & str ,
205+ ) -> Result < Option < crate :: models:: Connection > > {
152206 loop {
153- print ! ( "{} [1-{}, 's' to search again, 'q' to quit]: " , prompt, connections. len( ) ) ;
207+ print ! (
208+ "{} [1-{}, 's' to search again, 'q' to quit]: " ,
209+ prompt,
210+ connections. len( )
211+ ) ;
154212 io:: stdout ( ) . flush ( ) ?;
155213
156214 let mut input = String :: new ( ) ;
@@ -184,7 +242,10 @@ fn interactive_selection(connections: &[crate::models::Connection], prompt: &str
184242 if index >= 1 && index <= connections. len ( ) {
185243 return Ok ( Some ( connections[ index - 1 ] . clone ( ) ) ) ;
186244 } else {
187- println ! ( "Invalid selection. Please enter a number between 1 and {}." , connections. len( ) ) ;
245+ println ! (
246+ "Invalid selection. Please enter a number between 1 and {}." ,
247+ connections. len( )
248+ ) ;
188249 }
189250 } else {
190251 println ! ( "Invalid input. Please enter a number, 's' to search again, or 'q' to quit." ) ;
0 commit comments