aboutsummaryrefslogtreecommitdiffstats
path: root/bug
diff options
context:
space:
mode:
Diffstat (limited to 'bug')
-rw-r--r--bug/status.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/bug/status.go b/bug/status.go
index 0eee6cf1..f15924e2 100644
--- a/bug/status.go
+++ b/bug/status.go
@@ -1,5 +1,10 @@
package bug
+import (
+ "fmt"
+ "strings"
+)
+
type Status int
const (
@@ -29,3 +34,16 @@ func (s Status) Action() string {
return "unknown status"
}
}
+
+func StatusFromString(str string) (Status, error) {
+ cleaned := strings.ToLower(strings.TrimSpace(str))
+
+ switch cleaned {
+ case "open":
+ return OpenStatus, nil
+ case "closed":
+ return ClosedStatus, nil
+ default:
+ return 0, fmt.Errorf("unknow status")
+ }
+}