-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
55 lines (45 loc) · 938 Bytes
/
main.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
47
48
49
50
51
52
53
54
55
package main
import (
"log"
"os"
"github.com/urfave/cli/v2"
)
var (
// IP of machine running roverd
ip string
// port on main computer on which roverd is running
port string
)
var (
// addr is ip + ":" + port
addr string
)
func init() {
log.SetFlags(0)
log.SetPrefix("roverctl: ")
ip = os.Getenv("ROVERCTL_ROVER_IP")
port = os.Getenv("ROVERCTL_ROVERD_PORT")
addr = ip + ":" + port
log.Println("addr:", addr)
}
func main() {
app := &cli.App{
Name: "roverctl",
Usage: "control the Knurów rover command line",
OnUsageError: func(context *cli.Context, err error, isSubcommand bool) error {
log.Println("error:", err)
return nil
},
Commands: []*cli.Command{
&goCommand,
&turnCommand,
},
CommandNotFound: func(c *cli.Context, command string) {
log.Printf("invalid command '%s'. See 'roverctl --help'\n", command)
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatalln(err)
}
}