forked from jzelinskie/cobrautil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_test.go
38 lines (30 loc) · 807 Bytes
/
example_test.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
package cobrautil_test
import (
"github.com/rs/zerolog"
"github.com/spf13/cobra"
"github.com/jzelinskie/cobrautil"
)
func ExampleCommandStack() {
cmd := &cobra.Command{
Use: "mycmd",
PreRunE: cobrautil.CommandStack(
cobrautil.SyncViperPreRunE("myprogram"),
cobrautil.ZeroLogRunE("log", zerolog.InfoLevel),
),
}
cobrautil.RegisterZeroLogFlags(cmd.PersistentFlags(), "log")
}
func ExampleRegisterZeroLogFlags() {
cmd := &cobra.Command{
Use: "mycmd",
PreRunE: cobrautil.ZeroLogRunE("log", zerolog.InfoLevel),
}
cobrautil.RegisterZeroLogFlags(cmd.PersistentFlags(), "log")
}
func ExampleZeroLogRunE() {
cmd := &cobra.Command{
Use: "mycmd",
PreRunE: cobrautil.ZeroLogRunE("log", zerolog.InfoLevel),
}
cobrautil.RegisterZeroLogFlags(cmd.PersistentFlags(), "log")
}