Skip to content

Commit 856ac62

Browse files
committed
Stats: filter by tubes
1 parent 1cd5217 commit 856ac62

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cli/stats.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ var HighSeverityStyle = gocolorize.NewColor("white:red")
2121
var NormalSeverityStyle = gocolorize.NewColor("green")
2222

2323
type StatsCommand struct {
24+
Tubes string `short:"t" long:"tubes" description:"tubes to be listed (separated by ,). By default all are listed"`
25+
2426
Command
2527
}
2628

@@ -95,7 +97,7 @@ func addStyle(i int, l int, severity int) string {
9597
}
9698

9799
func (c *StatsCommand) GetStats() (map[string]*TubeStats, error) {
98-
tubes, err := c.conn.ListTubes()
100+
tubes, err := c.getTubesName()
99101
if err != nil {
100102
return nil, err
101103
}
@@ -113,6 +115,14 @@ func (c *StatsCommand) GetStats() (map[string]*TubeStats, error) {
113115
return stats, nil
114116
}
115117

118+
func (c *StatsCommand) getTubesName() ([]string, error) {
119+
if c.Tubes != "" {
120+
return strings.Split(strings.Replace(c.Tubes, " ", "", -1), ","), nil
121+
}
122+
123+
return c.conn.ListTubes()
124+
}
125+
116126
func mustConvertToInt(s string) int {
117127
i, err := strconv.Atoi(s)
118128
if err != nil {

0 commit comments

Comments
 (0)