cmd: test: would always run testCmdGlobalInit

This commit is contained in:
Christian Schwarz 2017-09-17 23:40:40 +02:00
parent 9cd83399d3
commit 1a62d635a6

View File

@ -16,8 +16,9 @@ import (
) )
var testCmd = &cobra.Command{ var testCmd = &cobra.Command{
Use: "test", Use: "test",
Short: "test configuration", Short: "test configuration",
PersistentPreRun: testCmdGlobalInit,
} }
var testCmdGlobal struct { var testCmdGlobal struct {
@ -51,7 +52,6 @@ var testPrunePolicyCmd = &cobra.Command{
} }
func init() { func init() {
cobra.OnInitialize(testCmdGlobalInit)
RootCmd.AddCommand(testCmd) RootCmd.AddCommand(testCmd)
testCmd.AddCommand(testConfigSyntaxCmd) testCmd.AddCommand(testConfigSyntaxCmd)
testCmd.AddCommand(testDatasetMapFilter) testCmd.AddCommand(testDatasetMapFilter)
@ -62,7 +62,7 @@ func init() {
testCmd.AddCommand(testPrunePolicyCmd) testCmd.AddCommand(testPrunePolicyCmd)
} }
func testCmdGlobalInit() { func testCmdGlobalInit(cmd *cobra.Command, args []string) {
testCmdGlobal.log = log.New(os.Stdout, "", 0) testCmdGlobal.log = log.New(os.Stdout, "", 0)