blob: 6305aac1c7ad8bb263e09e64f3b1f0ba1966953e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
}
|