diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-03-11 18:06:50 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-03-11 18:06:50 (GMT) |
commit | 453d7f9e7311b28802b194640792e2689073590c (patch) | |
tree | 43903c727eee3c9ae87f1cd2006b728883b0158b /rhimport | |
parent | cb4a3b0f857bf0c9c50387cb5dd0764a1082092d (diff) |
FilePolicy from and to string
Diffstat (limited to 'rhimport')
-rw-r--r-- | rhimport/core.go | 30 |
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 |