summaryrefslogtreecommitdiff
path: root/rhimport
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport')
-rw-r--r--rhimport/core.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/rhimport/core.go b/rhimport/core.go
index e6c6624..e1ba735 100644
--- a/rhimport/core.go
+++ b/rhimport/core.go
@@ -73,6 +73,36 @@ const (
DeleteWithDir
)
+func (p *FilePolicy) String() string {
+ switch *p {
+ case Auto:
+ return "auto"
+ case Keep:
+ return "keep"
+ case Delete:
+ return "delete"
+ case DeleteWithDir:
+ return "delete-with-dir"
+ }
+ return "unknown"
+}
+
+func (p *FilePolicy) FromString(str string) error {
+ switch str {
+ case "auto":
+ *p = Auto
+ case "keep":
+ *p = Keep
+ case "delete":
+ *p = Delete
+ case "delete-with-dir":
+ *p = DeleteWithDir
+ default:
+ return fmt.Errorf("must be on of: auto, keep, delete or delete-with-dir")
+ }
+ return nil
+}
+
type Context struct {
conf *Config
db *rddb.DBChan