@@ -3,6 +3,7 @@ package f2
33import (
44 "context"
55 "io"
6+ "log/slog"
67 "os"
78
89 "github.com/urfave/cli/v3"
@@ -28,50 +29,62 @@ func isOutputToPipe() bool {
2829}
2930
3031// execute initiates a new renaming operation based on the provided CLI context.
31- func execute (_ context.Context , cmd * cli.Command ) error {
32+ func execute (ctx context.Context , cmd * cli.Command ) error {
3233 appConfig , err := config .Init (cmd , isOutputToPipe ())
3334 if err != nil {
3435 return err
3536 }
3637
37- changes , err := find .Find (appConfig )
38+ slog .DebugContext (
39+ ctx ,
40+ "working configuration" ,
41+ slog .Any ("config" , appConfig ),
42+ )
43+
44+ matches , err := find .Find (appConfig )
3845 if err != nil {
3946 return err
4047 }
4148
42- if len (changes ) == 0 {
49+ slog .Debug (
50+ "find results" ,
51+ slog .Int ("count" , len (matches )),
52+ slog .Any ("matches" , matches ),
53+ )
54+
55+ if len (matches ) == 0 {
4356 report .NoMatches (appConfig )
4457
4558 return nil
4659 }
4760
4861 if ! appConfig .Revert {
49- changes , err = replace .Replace (appConfig , changes )
62+ matches , err = replace .Replace (appConfig , matches )
5063 if err != nil {
5164 return err
5265 }
5366 }
5467
5568 hasConflicts := validate .Validate (
56- changes ,
69+ matches ,
5770 appConfig .AutoFixConflicts ,
5871 appConfig .AllowOverwrites ,
5972 )
6073
6174 if hasConflicts {
62- report .Report (appConfig , changes , hasConflicts )
75+ report .Report (appConfig , matches , hasConflicts )
6376
6477 return errConflictDetected
6578 }
6679
6780 if ! appConfig .Exec {
68- report .Report (appConfig , changes , hasConflicts )
81+ report .Report (appConfig , matches , hasConflicts )
6982 return nil
7083 }
7184
72- err = rename .Rename (appConfig , changes )
85+ err = rename .Rename (appConfig , matches )
7386
74- rename .PostRename (appConfig , changes , err )
87+ rename .PostRename (appConfig , matches , err )
7588
7689 return err
7790}
0 commit comments