// SPDX-License-Identifier: GPL-3.0-or-later package plan import ( "fmt" "krino/internal/config" "krino/internal/scan" ) // Kind is what a step does. type Kind int const ( Copy Kind = iota Move Rename Trash // (delete) DeletePermanent // (delete permanent) ) // String is for display only; Task 5's JSON representation defines its own // action names. func (k Kind) String() string { switch k { case Copy: return "copy" case Move: return "move" case Rename: return "rename" case Trash: return "trash" case DeletePermanent: return "DELETE permanently" } return fmt.Sprintf("Kind(%d)", int(k)) } // Step is one action to carry out, already resolved to absolute paths. type Step struct { Kind Kind Rule string // the rule that contributed it Src string // absolute path the step reads from Dst string // absolute path the file has after the step; "" for the two deletes Reason string // the rule's match reasons, for display Skip string // non-empty: this step will not run, and why Conflict config.Conflict // the contributing rule's on-conflict policy Displaces string // overwrite only: the existing file that must be trashed first } // Chain is one file's steps, in order. type Chain struct { File scan.File Steps []Step Warnings []string } // RuleMatch is one matching rule's contribution to a file's chain. // internal/plan must not import internal/engine (engine imports plan), so // the engine converts its own types into these. type RuleMatch struct { Name string Actions []config.Action Settings config.Resolved Captures []string Reasons []string }