-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
46 lines (41 loc) · 956 Bytes
/
main.go
File metadata and controls
46 lines (41 loc) · 956 Bytes
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 main
import (
"context"
"errors"
"flag"
"log"
"os"
"github.com/overvenus/corplink-headless/pkg/headless"
)
var rpcConf = flag.String("rpc-conf", "./rpc.conf", "Path to rpc.conf file")
var companyCode = flag.String("company-code", "", "Company code for using Corplink")
var debug = flag.Bool("debug", false, "Enable debug mode")
func main() {
flag.Parse()
err := func() error {
if *companyCode == "" {
// Get from env
code := os.Getenv("COMPANY_CODE")
if code == "" {
return errors.New("company-code must not be empty")
}
*companyCode = code
}
token, err := headless.NewToken(*rpcConf)
if err != nil {
return err
}
if *debug {
log.Println("headless token:", token)
}
cli, err := headless.NewClient(headless.CorplinkServerAddr, *companyCode, token, *debug)
if err != nil {
return err
}
ctx := context.Background()
return cli.Run(ctx)
}()
if err != nil {
log.Printf("%s", err)
}
}