@@ -154,7 +154,7 @@ func defaultProvider() string {
154154 return "github"
155155}
156156
157- func InitConfig (cmd * cobra.Command ) error {
157+ func SetFlags (cmd * cobra.Command ) {
158158 cmd .Flags ().StringP ("token" , "t" , "" , "provider token" )
159159 cmd .Flags ().String ("provider" , defaultProvider (), "provider plugin name" )
160160 cmd .Flags ().StringArray ("provider-opt" , []string {}, "options that are passed to the provider plugin" )
@@ -183,12 +183,9 @@ func InitConfig(cmd *cobra.Command) error {
183183 cmd .Flags ().Bool ("prepend-changelog" , false , "if the changelog file already exist the new changelog is prepended" )
184184 cmd .Flags ().Bool ("download-plugins" , false , "downloads all required plugins if needed" )
185185 cmd .Flags ().Bool ("show-progress" , false , "shows the plugin download progress" )
186+ cmd .Flags ().String ("config" , "" , "config file (default is .semrelrc)" )
186187 cmd .Flags ().SortFlags = true
187188
188- viper .AddConfigPath ("." )
189- viper .SetConfigName (".semrelrc" )
190- viper .SetConfigType ("json" )
191-
192189 must (viper .BindPFlag ("maintainedVersion" , cmd .Flags ().Lookup ("maintained-version" )))
193190 must (viper .BindEnv ("maintainedVersion" , "MAINTAINED_VERSION" ))
194191
@@ -198,6 +195,17 @@ func InitConfig(cmd *cobra.Command) error {
198195 must (viper .BindPFlag ("plugins.changelog-generator.name" , cmd .Flags ().Lookup ("changelog-generator" )))
199196 must (viper .BindPFlag ("plugins.files-updater.names" , cmd .Flags ().Lookup ("files-updater" )))
200197 must (viper .BindPFlag ("plugins.hooks.names" , cmd .Flags ().Lookup ("hooks" )))
198+ }
199+
200+ func InitConfig (cmd * cobra.Command ) error {
201+ cfgFile := mustGetString (cmd , "config" )
202+ if cfgFile != "" {
203+ viper .SetConfigFile (cfgFile )
204+ } else {
205+ viper .AddConfigPath ("." )
206+ viper .SetConfigName (".semrelrc" )
207+ }
208+ viper .SetConfigType ("json" )
201209
202210 if err := viper .ReadInConfig (); err != nil {
203211 if _ , ok := err .(viper.ConfigFileNotFoundError ); ! ok {
0 commit comments