Skip to content

Commit da73a11

Browse files
committed
Use config.Navigate in command root
1 parent 4712662 commit da73a11

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

commands/root/root.go

+17-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
package root
1919

2020
import (
21+
"fmt"
2122
"io/ioutil"
2223
"os"
24+
"path/filepath"
2325

2426
"github.com/arduino/arduino-cli/output"
2527

@@ -115,6 +117,7 @@ func preRun(cmd *cobra.Command, args []string) {
115117

116118
// initConfigs initializes the configuration from the specified file.
117119
func initConfigs() {
120+
// Start with default configuration
118121
if conf, err := configs.NewConfiguration(); err != nil {
119122
logrus.WithError(err).Error("Error creating default configuration")
120123
formatter.PrintError(err, "Error creating default configuration")
@@ -123,14 +126,25 @@ func initConfigs() {
123126
commands.Config = conf
124127
}
125128

129+
// Navigate through folders
130+
pwd, err := filepath.Abs(".")
131+
if err != nil {
132+
logrus.WithError(err).Warn("Did not manage to find current path")
133+
}
134+
135+
commands.Config.Navigate("/", pwd)
136+
137+
fmt.Println(yamlConfigFile)
138+
126139
if yamlConfigFile != "" {
127140
commands.Config.ConfigFile = paths.New(yamlConfigFile)
141+
if err := commands.Config.LoadFromYAML(commands.Config.ConfigFile); err != nil {
142+
logrus.WithError(err).Warn("Did not manage to get config file, using default configuration")
143+
}
128144
}
129145

130146
logrus.Info("Initiating configuration")
131-
if err := commands.Config.LoadFromYAML(commands.Config.ConfigFile); err != nil {
132-
logrus.WithError(err).Warn("Did not manage to get config file, using default configuration")
133-
}
147+
134148
if commands.Config.IsBundledInDesktopIDE() {
135149
logrus.Info("CLI is bundled into the IDE")
136150
err := commands.Config.LoadFromDesktopIDEPreferences()

0 commit comments

Comments
 (0)