From 1a62d635a66b313b6976ccd45907e3dfd5e44440 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sun, 17 Sep 2017 23:40:40 +0200 Subject: [PATCH] cmd: test: would always run testCmdGlobalInit --- cmd/test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/test.go b/cmd/test.go index a1a519b..17ce178 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -16,8 +16,9 @@ import ( ) var testCmd = &cobra.Command{ - Use: "test", - Short: "test configuration", + Use: "test", + Short: "test configuration", + PersistentPreRun: testCmdGlobalInit, } var testCmdGlobal struct { @@ -51,7 +52,6 @@ var testPrunePolicyCmd = &cobra.Command{ } func init() { - cobra.OnInitialize(testCmdGlobalInit) RootCmd.AddCommand(testCmd) testCmd.AddCommand(testConfigSyntaxCmd) testCmd.AddCommand(testDatasetMapFilter) @@ -62,7 +62,7 @@ func init() { testCmd.AddCommand(testPrunePolicyCmd) } -func testCmdGlobalInit() { +func testCmdGlobalInit(cmd *cobra.Command, args []string) { testCmdGlobal.log = log.New(os.Stdout, "", 0)