From 0521b613b42776e0e601129e52dee20ff7cb3951 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 18 Feb 2019 11:53:30 +0100 Subject: [PATCH] Do not bail out if old-style config file is found We will remove support for old-style config in the next release. This will allow a smooth transition to the new file name. --- commands/root/root.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/commands/root/root.go b/commands/root/root.go index 471d65bc579..ffad0100058 100644 --- a/commands/root/root.go +++ b/commands/root/root.go @@ -116,16 +116,6 @@ func preRun(cmd *cobra.Command, args []string) { // initConfigs initializes the configuration from the specified file. func initConfigs() { - // Return error if an old configuration file is found - if old := paths.New(".cli-config.yml"); old.Exist() { - logrus.Errorf("Old configuration file detected: %s.", old) - logrus.Info("The name of this file has been changed to `arduino-cli.yaml`, please rename the file fix it.") - formatter.PrintError( - fmt.Errorf("old configuration file detected: %s", old), - "The name of this file has been changed to `arduino-cli.yaml`, please rename the file fix it.") - os.Exit(commands.ErrGeneric) - } - // Start with default configuration if conf, err := configs.NewConfiguration(); err != nil { logrus.WithError(err).Error("Error creating default configuration") @@ -160,6 +150,17 @@ func initConfigs() { commands.Config.Navigate("/", pwd.String()) } + // Read configuration from old configuration file if found, but output a warning. + if old := paths.New(".cli-config.yml"); old.Exist() { + logrus.Errorf("Old configuration file detected: %s.", old) + logrus.Info("The name of this file has been changed to `arduino-cli.yaml`, please rename the file fix it.") + formatter.PrintError( + fmt.Errorf("WARNING: Old configuration file detected: %s", old), + "The name of this file has been changed to `arduino-cli.yaml`, in a future release we will not support"+ + "the old name `.cli-config.yml` anymore. Please rename the file to `arduino-cli.yaml` to silence this warning.") + readConfigFrom(old) + } + // Read configuration from environment vars commands.Config.LoadFromEnv()