bugfix: using default value flag parameter

This commit is contained in:
Baipyrus 2024-09-13 00:29:15 +02:00
parent 9e72eb5171
commit 777de8f144

View File

@ -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"
}
}