@@ -42,13 +42,13 @@ import (
42
42
"github.com/arduino/arduino-cli/cli/upgrade"
43
43
"github.com/arduino/arduino-cli/cli/upload"
44
44
"github.com/arduino/arduino-cli/cli/version"
45
+ "github.com/arduino/arduino-cli/configuration"
45
46
"github.com/arduino/arduino-cli/i18n"
46
47
"github.com/arduino/arduino-cli/inventory"
47
48
"github.com/mattn/go-colorable"
48
49
"github.com/rifflock/lfshook"
49
50
"github.com/sirupsen/logrus"
50
51
"github.com/spf13/cobra"
51
- "github.com/spf13/viper"
52
52
)
53
53
54
54
var (
@@ -99,15 +99,15 @@ func createCliCommandTree(cmd *cobra.Command) {
99
99
100
100
cmd .PersistentFlags ().BoolVarP (& verbose , "verbose" , "v" , false , "Print the logs on the standard output." )
101
101
cmd .PersistentFlags ().String ("log-level" , "" , "Messages with this level and above will be logged. Valid levels are: trace, debug, info, warn, error, fatal, panic" )
102
- viper .BindPFlag ("logging.level" , cmd .PersistentFlags ().Lookup ("log-level" ))
102
+ configuration . Settings .BindPFlag ("logging.level" , cmd .PersistentFlags ().Lookup ("log-level" ))
103
103
cmd .PersistentFlags ().String ("log-file" , "" , "Path to the file where logs will be written." )
104
- viper .BindPFlag ("logging.file" , cmd .PersistentFlags ().Lookup ("log-file" ))
104
+ configuration . Settings .BindPFlag ("logging.file" , cmd .PersistentFlags ().Lookup ("log-file" ))
105
105
cmd .PersistentFlags ().String ("log-format" , "" , "The output format for the logs, can be {text|json}." )
106
- viper .BindPFlag ("logging.format" , cmd .PersistentFlags ().Lookup ("log-format" ))
106
+ configuration . Settings .BindPFlag ("logging.format" , cmd .PersistentFlags ().Lookup ("log-format" ))
107
107
cmd .PersistentFlags ().StringVar (& outputFormat , "format" , "text" , "The output format, can be {text|json}." )
108
108
cmd .PersistentFlags ().StringVar (& configFile , "config-file" , "" , "The custom config file (if not specified the default will be used)." )
109
109
cmd .PersistentFlags ().StringSlice ("additional-urls" , []string {}, "Comma-separated list of additional URLs for the Boards Manager." )
110
- viper .BindPFlag ("board_manager.additional_urls" , cmd .PersistentFlags ().Lookup ("additional-urls" ))
110
+ configuration . Settings .BindPFlag ("board_manager.additional_urls" , cmd .PersistentFlags ().Lookup ("additional-urls" ))
111
111
}
112
112
113
113
// convert the string passed to the `--log-level` option to the corresponding
@@ -136,10 +136,10 @@ func parseFormatString(arg string) (feedback.OutputFormat, bool) {
136
136
}
137
137
138
138
func preRun (cmd * cobra.Command , args []string ) {
139
- configFile := viper .ConfigFileUsed ()
139
+ configFile := configuration . Settings .ConfigFileUsed ()
140
140
141
141
// initialize inventory
142
- inventory .Init (viper .GetString ("directories.Data" ))
142
+ inventory .Init (configuration . Settings .GetString ("directories.Data" ))
143
143
144
144
//
145
145
// Prepare logging
@@ -157,13 +157,13 @@ func preRun(cmd *cobra.Command, args []string) {
157
157
}
158
158
159
159
// set the Logger format
160
- logFormat := strings .ToLower (viper .GetString ("logging.format" ))
160
+ logFormat := strings .ToLower (configuration . Settings .GetString ("logging.format" ))
161
161
if logFormat == "json" {
162
162
logrus .SetFormatter (& logrus.JSONFormatter {})
163
163
}
164
164
165
165
// should we log to file?
166
- logFile := viper .GetString ("logging.file" )
166
+ logFile := configuration . Settings .GetString ("logging.file" )
167
167
if logFile != "" {
168
168
file , err := os .OpenFile (logFile , os .O_CREATE | os .O_WRONLY | os .O_APPEND , 0666 )
169
169
if err != nil {
@@ -180,8 +180,8 @@ func preRun(cmd *cobra.Command, args []string) {
180
180
}
181
181
182
182
// configure logging filter
183
- if lvl , found := toLogLevel (viper .GetString ("logging.level" )); ! found {
184
- feedback .Errorf ("Invalid option for --log-level: %s" , viper .GetString ("logging.level" ))
183
+ if lvl , found := toLogLevel (configuration . Settings .GetString ("logging.level" )); ! found {
184
+ feedback .Errorf ("Invalid option for --log-level: %s" , configuration . Settings .GetString ("logging.level" ))
185
185
os .Exit (errorcodes .ErrBadArgument )
186
186
} else {
187
187
logrus .SetLevel (lvl )
0 commit comments