-
Notifications
You must be signed in to change notification settings - Fork 7
/
registration.go
46 lines (39 loc) · 1.05 KB
/
registration.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package streamdeck
import (
"flag"
"fmt"
)
type RegistrationParams struct {
Port int
PluginUUID string
RegisterEvent string
Info string
}
func ParseRegistrationParams(args []string) (RegistrationParams, error) {
f := flag.NewFlagSet("registration_params", flag.ContinueOnError)
port := f.Int("port", -1, "")
pluginUUID := f.String("pluginUUID", "", "")
registerEvent := f.String("registerEvent", "", "")
info := f.String("info", "", "")
if err := f.Parse(args[1:]); err != nil {
return RegistrationParams{}, err
}
if *port == -1 {
return RegistrationParams{}, fmt.Errorf("missing -port flag")
}
if *pluginUUID == "" {
return RegistrationParams{}, fmt.Errorf("missing -pluginUUID flag")
}
if *registerEvent == "" {
return RegistrationParams{}, fmt.Errorf("missing -registerEvent flag")
}
if *info == "" {
return RegistrationParams{}, fmt.Errorf("missing -info flag")
}
return RegistrationParams{
Port: *port,
PluginUUID: *pluginUUID,
RegisterEvent: *registerEvent,
Info: *info,
}, nil
}