11package cli
22
33import (
4+ "fmt"
5+
6+ "github.com/agtorre/gocolorize"
47 "github.com/kr/beanstalk"
58)
69
10+ var TitleStyle = gocolorize .NewColor ("green" )
11+ var InfoStyle = gocolorize .NewColor ("yellow" )
12+
713type Command struct {
814 Host string `short:"h" long:"host" description:"beanstalkd host addr." required:"true" default:"localhost:11300"`
915
@@ -20,6 +26,35 @@ func (c *Command) Init() error {
2026 return nil
2127}
2228
29+ func (c * Command ) PrintJob (id uint64 , body []byte ) error {
30+ s , err := c .conn .StatsJob (id )
31+ if err != nil {
32+ return err
33+ }
34+
35+ fmt .Printf (
36+ "%s: %d, %s: %d, %s: %s, %s: %s, %s: %s, %s: %s\n " +
37+ "%s: %s, %s: %s, %s: %s, %s: %s, %s: %s\n " +
38+ "%s:\n %q\n " ,
39+ TitleStyle .Paint ("id" ), id ,
40+ TitleStyle .Paint ("length" ), len (body ),
41+ TitleStyle .Paint ("priority" ), s ["pri" ],
42+ TitleStyle .Paint ("delay" ), s ["delay" ],
43+ TitleStyle .Paint ("age" ), s ["age" ],
44+ TitleStyle .Paint ("ttr" ), s ["ttr" ],
45+
46+ InfoStyle .Paint ("reserves" ), s ["reserves" ],
47+ InfoStyle .Paint ("releases" ), s ["releases" ],
48+ InfoStyle .Paint ("buries" ), s ["buries" ],
49+ InfoStyle .Paint ("kicks" ), s ["kicks" ],
50+ InfoStyle .Paint ("timeouts" ), s ["timeouts" ],
51+
52+ InfoStyle .Paint ("body" ), body ,
53+ )
54+
55+ return nil
56+ }
57+
2358func (c * Command ) GetStatsForTube (tube string ) (* TubeStats , error ) {
2459 t := & beanstalk.Tube {c .conn , tube }
2560 s , err := t .Stats ()
0 commit comments