-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.go
More file actions
50 lines (39 loc) · 1018 Bytes
/
main.go
File metadata and controls
50 lines (39 loc) · 1018 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
47
48
49
50
// Copyright 2014 The gocui Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"flag"
"strings"
"github.com/liyue201/lazyredis/config"
"github.com/liyue201/lazyredis/gui"
"github.com/liyue201/lazyredis/redis"
)
var (
addr = flag.String("addr", "localhost:6379", "redis address")
pass = flag.String("pass", "", "redis password")
db = flag.Int("db", 0, "redis database")
cfgFile = flag.String("conf", "", "yaml config file")
)
func main() {
flag.Parse()
redisAddrs := strings.Split(*addr, ",")
if *cfgFile != "" {
conf, err := config.Load(*cfgFile)
if err != nil {
panic(err.Error())
}
redisAddrs = conf.Redis.Addr
*pass = conf.Redis.Password
*db = conf.Redis.Db
}
redisCli, err := redis.NewRedisClient(redisAddrs, *pass, *db)
if err != nil {
panic(err.Error())
}
defer redisCli.Close()
w := gui.NewWindow()
w.SetRedisClient(redisCli)
w.Run()
w.Close()
}