summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/matterbridge/gozulipbot/flag.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/matterbridge/gozulipbot/flag.go')
-rw-r--r--vendor/github.com/matterbridge/gozulipbot/flag.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/vendor/github.com/matterbridge/gozulipbot/flag.go b/vendor/github.com/matterbridge/gozulipbot/flag.go
new file mode 100644
index 00000000..6305aac1
--- /dev/null
+++ b/vendor/github.com/matterbridge/gozulipbot/flag.go
@@ -0,0 +1,32 @@
+package gozulipbot
+
+import (
+ "flag"
+ "fmt"
+ "time"
+)
+
+func (b *Bot) GetConfigFromFlags() error {
+ var (
+ apiKey = flag.String("apikey", "", "bot api key")
+ apiURL = flag.String("apiurl", "", "url of zulip server")
+ email = flag.String("email", "", "bot email address")
+ backoff = flag.Duration("backoff", 1*time.Second, "backoff base duration")
+ )
+ flag.Parse()
+
+ if *apiKey == "" {
+ return fmt.Errorf("--apikey is required")
+ }
+ if *apiURL == "" {
+ return fmt.Errorf("--apiurl is required")
+ }
+ if *email == "" {
+ return fmt.Errorf("--email is required")
+ }
+ b.APIKey = *apiKey
+ b.APIURL = *apiURL
+ b.Email = *email
+ b.Backoff = *backoff
+ return nil
+}