11use crate :: error:: GitAiError ;
22use indicatif:: { ProgressBar , ProgressStyle } ;
3- use serde_json:: { json , Value } ;
3+ use serde_json:: { Value , json } ;
44use std:: fs;
55use std:: io:: Write ;
66use std:: path:: { Path , PathBuf } ;
@@ -50,7 +50,7 @@ fn check_claude_code() -> bool {
5050
5151 // Sometimes the binary won't be in the PATH, but the dotfiles will be
5252 let home = std:: env:: var ( "HOME" ) . unwrap_or_else ( |_| "." . to_string ( ) ) ;
53- return Path :: new ( & home) . join ( ".claude" ) . exists ( )
53+ return Path :: new ( & home) . join ( ".claude" ) . exists ( ) ;
5454}
5555
5656fn check_cursor ( ) -> bool {
@@ -63,7 +63,7 @@ fn check_cursor() -> bool {
6363
6464 // Sometimes the binary won't be in the PATH, but the dotfiles will be
6565 let home = std:: env:: var ( "HOME" ) . unwrap_or_else ( |_| "." . to_string ( ) ) ;
66- return Path :: new ( & home) . join ( ".cursor" ) . exists ( )
66+ return Path :: new ( & home) . join ( ".cursor" ) . exists ( ) ;
6767}
6868
6969// Shared utilities
@@ -190,10 +190,7 @@ fn install_cursor_hooks() -> Result<(), GitAiError> {
190190 }
191191
192192 // Merge hooks object
193- let mut hooks_obj = merged
194- . get ( "hooks" )
195- . cloned ( )
196- . unwrap_or_else ( || json ! ( { } ) ) ;
193+ let mut hooks_obj = merged. get ( "hooks" ) . cloned ( ) . unwrap_or_else ( || json ! ( { } ) ) ;
197194
198195 // AfterEdit desired entries
199196 let desired_after = desired
@@ -245,13 +242,18 @@ fn install_cursor_hooks() -> Result<(), GitAiError> {
245242
246243fn merge_hooks ( existing : Option < & Value > , desired : Option < & Value > ) -> Option < Value > {
247244 let mut result = existing. cloned ( ) . unwrap_or_else ( || json ! ( { } ) ) ;
248- let desired = match desired { Some ( v) => v, None => return Some ( result) } ;
245+ let desired = match desired {
246+ Some ( v) => v,
247+ None => return Some ( result) ,
248+ } ;
249249
250250 // Merge arrays by matcher for PreToolUse and PostToolUse. Append missing hooks, avoid duplicates.
251251 if let Some ( obj) = result. as_object_mut ( ) {
252252 for key in [ "PreToolUse" , "PostToolUse" ] . iter ( ) {
253253 let desired_arr = desired. get ( * key) . and_then ( |v| v. as_array ( ) ) ;
254- if desired_arr. is_none ( ) { continue ; }
254+ if desired_arr. is_none ( ) {
255+ continue ;
256+ }
255257 let desired_arr = desired_arr. unwrap ( ) ;
256258
257259 let mut existing_arr = obj
@@ -271,7 +273,9 @@ fn merge_hooks(existing: Option<&Value>, desired: Option<&Value>) -> Option<Valu
271273
272274 for desired_item in desired_arr {
273275 let desired_matcher = desired_item. get ( "matcher" ) . and_then ( |m| m. as_str ( ) ) ;
274- if desired_matcher. is_none ( ) { continue ; }
276+ if desired_matcher. is_none ( ) {
277+ continue ;
278+ }
275279 let desired_matcher = desired_matcher. unwrap ( ) ;
276280
277281 // Find or create the block for this matcher
@@ -297,10 +301,15 @@ fn merge_hooks(existing: Option<&Value>, desired: Option<&Value>) -> Option<Valu
297301 if let Some ( desired_hooks) = desired_hooks {
298302 for d in desired_hooks {
299303 let duplicate = target_hooks. iter ( ) . any ( |e| {
300- if e == d { return true ; }
304+ if e == d {
305+ return true ;
306+ }
301307 let dc = d. get ( "command" ) . and_then ( |c| c. as_str ( ) ) ;
302308 let ec = e. get ( "command" ) . and_then ( |c| c. as_str ( ) ) ;
303- match ( dc, ec) { ( Some ( a) , Some ( b) ) => a == b, _ => false }
309+ match ( dc, ec) {
310+ ( Some ( a) , Some ( b) ) => a == b,
311+ _ => false ,
312+ }
304313 } ) ;
305314 if !duplicate {
306315 target_hooks. push ( d. clone ( ) ) ;
@@ -370,11 +379,11 @@ impl Spinner {
370379 // Spinner starts automatically when created
371380 }
372381
373- fn update_message ( & self , message : & str ) {
382+ fn _update_message ( & self , message : & str ) {
374383 self . pb . set_message ( message. to_string ( ) ) ;
375384 }
376385
377- async fn wait_for ( & self , duration_ms : u64 ) {
386+ async fn _wait_for ( & self , duration_ms : u64 ) {
378387 smol:: Timer :: after ( std:: time:: Duration :: from_millis ( duration_ms) ) . await ;
379388 }
380389
0 commit comments