aboutsummaryrefslogtreecommitdiff
path: root/internal/plan/step.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/plan/step.go')
-rw-r--r--internal/plan/step.go69
1 files changed, 69 insertions, 0 deletions
diff --git a/internal/plan/step.go b/internal/plan/step.go
new file mode 100644
index 0000000..e4f280f
--- /dev/null
+++ b/internal/plan/step.go
@@ -0,0 +1,69 @@
+// 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
+}