Add regex command implementation

This commit is contained in:
Rogee
2025-10-31 10:12:02 +08:00
parent a0d7084c28
commit d436970848
55 changed files with 2115 additions and 9 deletions

47
internal/regex/summary.go Normal file
View File

@@ -0,0 +1,47 @@
package regex
// Summary describes the outcome of previewing or applying a regex rename request.
type Summary struct {
TotalCandidates int
Matched int
Changed int
Skipped int
Conflicts []Conflict
Warnings []string
Entries []PreviewEntry
LedgerMetadata map[string]any
}
// ConflictReason enumerates reasons a proposed rename cannot proceed.
type ConflictReason string
const (
ConflictDuplicateTarget ConflictReason = "duplicate_target"
ConflictExistingFile ConflictReason = "existing_file"
ConflictExistingDir ConflictReason = "existing_directory"
ConflictInvalidTemplate ConflictReason = "invalid_template"
)
// Conflict reports a blocked rename candidate to the CLI and callers.
type Conflict struct {
OriginalPath string
ProposedPath string
Reason ConflictReason
}
// EntryStatus captures the preview disposition for a candidate path.
type EntryStatus string
const (
EntryChanged EntryStatus = "changed"
EntryNoChange EntryStatus = "no_change"
EntrySkipped EntryStatus = "skipped"
)
// PreviewEntry documents a single rename candidate and the proposed output.
type PreviewEntry struct {
OriginalPath string
ProposedPath string
Status EntryStatus
MatchGroups []string
}