add ai feature

This commit is contained in:
2025-11-05 16:06:09 +08:00
parent 42bc9aff42
commit 13ca7ddbed
33 changed files with 2194 additions and 30 deletions

View File

@@ -0,0 +1,40 @@
package output
import (
"fmt"
"io"
)
// ProgressReporter prints textual progress for rename operations.
type ProgressReporter struct {
writer io.Writer
total int
count int
}
// NewProgressReporter constructs a reporter bound to the supplied writer.
func NewProgressReporter(w io.Writer, total int) *ProgressReporter {
if w == nil {
w = io.Discard
}
return &ProgressReporter{writer: w, total: total}
}
// Step registers a completed operation and prints the progress.
func (r *ProgressReporter) Step(from, to string) error {
if r == nil {
return nil
}
r.count++
_, err := fmt.Fprintf(r.writer, "[%d/%d] %s -> %s\n", r.count, r.total, from, to)
return err
}
// Complete emits a summary line after all operations finish.
func (r *ProgressReporter) Complete() error {
if r == nil {
return nil
}
_, err := fmt.Fprintf(r.writer, "Completed %d rename(s).\n", r.count)
return err
}