11use anyhow:: { anyhow, Context , Result } ;
22use regex:: Regex ;
3- use renamify_core:: {
4- apply_plan, create_simple_plan, Plan , PlanOptions , Preview ,
5- } ;
3+ use renamify_core:: { apply_plan, create_simple_plan, Plan , PlanOptions , Preview } ;
64use serde_json;
75use std:: io:: { self , Write } ;
86use std:: path:: PathBuf ;
@@ -58,16 +56,17 @@ pub fn handle_replace(
5856 create_simple_plan ( pattern, replacement, paths, & options, false ) ?
5957 } else {
6058 // Regex replacement - validate the pattern first
61- Regex :: new ( pattern)
62- . with_context ( || format ! ( "Invalid regex pattern: {}" , pattern) ) ?;
63-
59+ Regex :: new ( pattern) . with_context ( || format ! ( "Invalid regex pattern: {}" , pattern) ) ?;
60+
6461 // Create plan with regex replacement
6562 create_simple_plan ( pattern, replacement, paths, & options, true ) ?
6663 } ;
6764
6865 // Check for large changes
6966 if !large && !yes {
70- let total_files = plan. matches . iter ( )
67+ let total_files = plan
68+ . matches
69+ . iter ( )
7170 . map ( |m| & m. file )
7271 . collect :: < std:: collections:: HashSet < _ > > ( )
7372 . len ( ) ;
@@ -101,9 +100,7 @@ pub fn handle_replace(
101100
102101 // Show preview if not in quiet mode
103102 if !quiet && !dry_run {
104- let preview_format = preview
105- . map ( |p| p. into ( ) )
106- . unwrap_or ( Preview :: Table ) ;
103+ let preview_format = preview. map ( |p| p. into ( ) ) . unwrap_or ( Preview :: Table ) ;
107104
108105 let output = renamify_core:: render_plan ( & plan, preview_format, Some ( use_color) ) ;
109106 print ! ( "{}" , output) ;
@@ -170,7 +167,11 @@ fn commit_changes(plan: &Plan) -> Result<()> {
170167 . matches
171168 . iter ( )
172169 . map ( |m| m. file . to_string_lossy ( ) . to_string ( ) )
173- . chain ( plan. paths . iter ( ) . map ( |r| r. new_path . to_string_lossy ( ) . to_string ( ) ) )
170+ . chain (
171+ plan. paths
172+ . iter ( )
173+ . map ( |r| r. new_path . to_string_lossy ( ) . to_string ( ) ) ,
174+ )
174175 . collect :: < std:: collections:: HashSet < _ > > ( )
175176 . into_iter ( )
176177 . collect ( ) ;
@@ -188,10 +189,7 @@ fn commit_changes(plan: &Plan) -> Result<()> {
188189 }
189190
190191 // Create commit message
191- let message = format ! (
192- "Replace '{}' with '{}'" ,
193- plan. search, plan. replace
194- ) ;
192+ let message = format ! ( "Replace '{}' with '{}'" , plan. search, plan. replace) ;
195193
196194 let status = Command :: new ( "git" )
197195 . args ( & [ "commit" , "-m" , & message] )
@@ -203,4 +201,4 @@ fn commit_changes(plan: &Plan) -> Result<()> {
203201 }
204202
205203 Ok ( ( ) )
206- }
204+ }
0 commit comments