-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
54 lines (49 loc) · 1.13 KB
/
main.go
File metadata and controls
54 lines (49 loc) · 1.13 KB
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
51
52
53
54
package main
import (
"fmt"
"github.com/urfave/cli"
"time"
)
func main() {
app := cli.NewApp()
app.Name = "bucky"
app.Usage = "Produce a periodic bucky message"
app.Version = "0.1.0"
app.Flags = []cli.Flag{
cli.BoolTFlag{
Name: "verbose",
Usage: "Print verbose output",
},
}
app.Commands = []cli.Command{
{
Name: "version",
Aliases: []string{"v"},
Usage: "Print the version and exit",
Action: func(c *cli.Context) error {
fmt.Printf("bucky version %s\n", app.Version)
return nil
},
},
{
Name: "generate",
Usage: "Generate log messages",
Action: RunPeriodically,
Flags: []cli.Flag{
cli.StringFlag{
Name: "format",
Usage: "Specify the output format: text, json",
}, cli.DurationFlag{
Name: "period",
Usage: "Specify the period between starting log message emitters. Valid time units are 'ns', 'us' (or 'µs'), 'ms', 's', 'm', 'h' (default: 1s)",
Value: 1 * time.Second,
}, cli.Uint64Flag{
Name: "count",
Usage: "Specify the count of messages emitted per period (default: 1)",
Value: 1,
},
},
},
}
app.RunAndExitOnError()
}