-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
52 lines (43 loc) · 1.01 KB
/
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
package main
import (
"flag"
"fmt"
"github.com/c-bata/go-prompt"
_ "github.com/pingcap/parser/test_driver"
"os"
"tikv-client/client"
"tikv-client/util"
)
func main() {
pdEndPoint := ParseArgs()
// For self debug
if pdEndPoint == "" {
pdEndPoint = "172.16.101.3:2479"
}
c, err := client.NewCompleter(pdEndPoint)
if err != nil {
fmt.Printf(util.Red("Can't connect to placement driver\nError: %s\n"), err)
os.Exit(0)
}
client.Welcome(*c.PlacementDriverGroup, client.Ticlient_)
defer func() {
fmt.Println("GoodBye!")
}()
prpt := prompt.New(
c.Executor,
c.Complete,
prompt.OptionPrefix(">>>> "),
prompt.OptionSuggestionBGColor(prompt.Red),
prompt.OptionSuggestionTextColor(prompt.White),
prompt.OptionDescriptionBGColor(prompt.White),
prompt.OptionDescriptionTextColor(prompt.Black),
prompt.OptionTitle(client.Ticlient_),
)
prpt.Run()
}
func ParseArgs() string {
var pdEndPoint string
flag.StringVar(&pdEndPoint, "pd", "", "Placement driver endpoint")
flag.Parse()
return pdEndPoint
}