aboutsummaryrefslogtreecommitdiffstats
path: root/bug
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-09 20:13:46 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-09 20:13:46 +0200
commit877f3bc21ef6bb1ae636caaad8f62733f6de2f72 (patch)
tree533308ef5ff34450f4e94c310e00728a122c1839 /bug
parent6d7e79a277fe6f3d137fc76588599c965fa5b2ee (diff)
downloadgit-bug-877f3bc21ef6bb1ae636caaad8f62733f6de2f72.tar.gz
status: add a function to parse a status
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")
+ }
+}