forked from src-d/beanstool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
beanstool.go
34 lines (28 loc) · 1.06 KB
/
beanstool.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
package main
import (
"os"
"github.com/agtorre/gocolorize"
"github.com/jessevdk/go-flags"
"github.com/src-d/beanstool/cli"
"golang.org/x/crypto/ssh/terminal"
)
func main() {
if !terminal.IsTerminal(int(os.Stdout.Fd())) {
gocolorize.SetPlain(true)
}
parser := flags.NewNamedParser("beanstool", flags.Default)
parser.AddCommand("stats", "print stats on all tubes", "", &cli.StatsCommand{})
parser.AddCommand("tail", "tails a tube and prints his content", "", &cli.TailCommand{})
parser.AddCommand("peek", "peeks a job from a queue", "", &cli.PeekCommand{})
parser.AddCommand("delete", "delete a job from a queue", "", &cli.DeleteCommand{})
parser.AddCommand("kick", "kicks jobs from buried back into ready", "", &cli.KickCommand{})
parser.AddCommand("put", "put a job into a tube", "", &cli.PutCommand{})
parser.AddCommand("bury", "bury existing jobs from ready state", "", &cli.BuryCommand{})
_, err := parser.Parse()
if err != nil {
if flagErr, ok := err.(*flags.Error); ok && flagErr.Type != flags.ErrHelp {
parser.WriteHelp(os.Stdout)
}
os.Exit(1)
}
}