From 777de8f14480cbcd2a80c8eb4d42fa2481eb0f1c Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Fri, 13 Sep 2024 00:29:15 +0200 Subject: [PATCH] bugfix: using default value flag parameter --- cmd/root.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 528366f..79589a3 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -29,22 +29,14 @@ func Execute() { } func init() { - cobra.OnInitialize(initConfig) - // Here you will define your flags and configuration settings. // Cobra supports persistent flags, which, if defined here, // will be global for your application. - rootCmd.PersistentFlags().StringVar(&cfgFile, "configs", "c", "configs file (default is 'configs.json' in cwd)") + rootCmd.PersistentFlags().StringVarP(&cfgFile, "configs", "c", "configs.json", "configurations file") // Cobra also supports local flags, which will only run // when this action is called directly. // rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") } - -func initConfig() { - if cfgFile == "" { - cfgFile = "configs.json" - } -}