-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinfo.go
45 lines (37 loc) · 972 Bytes
/
info.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
package main
import (
"errors"
"fmt"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
)
// info host:port
var infoCommand = cli.Command{
Name: "info",
Usage: "display the info of redis cluster.",
ArgsUsage: `host:port`,
Description: `The info command get info from redis cluster.`,
Action: func(context *cli.Context) error {
if context.NArg() != 1 {
fmt.Printf("Incorrect Usage.\n\n")
cli.ShowCommandHelp(context, "info")
logrus.Fatalf("Must provide host:port for info command!")
}
rt := NewRedisTrib()
if err := rt.InfoClusterCmd(context); err != nil {
return err
}
return nil
},
}
func (self *RedisTrib) InfoClusterCmd(context *cli.Context) error {
var addr string
if addr = context.Args().Get(0); addr == "" {
return errors.New("please check host:port for info command")
}
if err := self.LoadClusterInfoFromNode(addr); err != nil {
return err
}
self.ShowClusterInfo()
return nil
}