Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3df8397

Browse filesBrowse files
committed
move vars to global
1 parent 8f5a4d7 commit 3df8397
Copy full SHA for 3df8397

File tree

Expand file treeCollapse file tree

2 files changed

+9
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-9
lines changed

‎cli/cli.go

Copy file name to clipboardExpand all lines: cli/cli.go
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import (
2525

2626
"github.com/arduino/arduino-fwuploader/cli/certificates"
2727
"github.com/arduino/arduino-fwuploader/cli/common"
28+
"github.com/arduino/arduino-fwuploader/cli/feedback"
2829
"github.com/arduino/arduino-fwuploader/cli/firmware"
30+
"github.com/arduino/arduino-fwuploader/cli/globals"
2931
"github.com/arduino/arduino-fwuploader/cli/version"
30-
31-
"github.com/arduino/arduino-fwuploader/cli/feedback"
3232
v "github.com/arduino/arduino-fwuploader/version"
3333
"github.com/mattn/go-colorable"
3434
"github.com/rifflock/lfshook"
@@ -38,10 +38,8 @@ import (
3838

3939
var (
4040
outputFormat string
41-
verbose bool
4241
logFile string
4342
logFormat string
44-
logLevel string
4543
additionalFirmwareURLs []string
4644
additionalPackageURLs []string
4745
)
@@ -64,8 +62,8 @@ func NewCommand() *cobra.Command {
6462
rootCmd.PersistentFlags().StringVar(&outputFormat, "format", "text", "The output format, can be {text|json}.")
6563
rootCmd.PersistentFlags().StringVar(&logFile, "log-file", "", "Path to the file where logs will be written")
6664
rootCmd.PersistentFlags().StringVar(&logFormat, "log-format", "", "The output format for the logs, can be {text|json}.")
67-
rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "Messages with this level and above will be logged. Valid levels are: trace, debug, info, warn, error, fatal, panic")
68-
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Print the logs on the standard output.")
65+
rootCmd.PersistentFlags().StringVar(&globals.LogLevel, "log-level", "info", "Messages with this level and above will be logged. Valid levels are: trace, debug, info, warn, error, fatal, panic")
66+
rootCmd.PersistentFlags().BoolVarP(&globals.Verbose, "verbose", "v", false, "Print the logs on the standard output.")
6967
rootCmd.PersistentFlags().StringArrayVarP(&additionalFirmwareURLs, "additional-fw-index", "F", nil, "Additional firmwares index URLs (useful for testing purposes)")
7068
rootCmd.PersistentFlags().StringArrayVarP(&additionalPackageURLs, "additional-packages-index", "P", nil, "Additional packages index URLs (useful for testing purposes)")
7169
return rootCmd
@@ -97,7 +95,7 @@ func preRun(cmd *cobra.Command, args []string) {
9795
feedback.SetFormat(format)
9896

9997
// Prepare logging
100-
if verbose {
98+
if globals.Verbose {
10199
// if we print on stdout, do it in full colors
102100
logrus.SetOutput(colorable.NewColorableStdout())
103101
logrus.SetFormatter(&logrus.TextFormatter{
@@ -128,8 +126,8 @@ func preRun(cmd *cobra.Command, args []string) {
128126
}
129127

130128
// Configure logging filter
131-
if lvl, found := toLogLevel(logLevel); !found {
132-
feedback.Fatal(fmt.Sprintf("Invalid option for --log-level: %s", logLevel), feedback.ErrBadArgument)
129+
if lvl, found := toLogLevel(globals.LogLevel); !found {
130+
feedback.Fatal(fmt.Sprintf("Invalid option for --log-level: %s", globals.LogLevel), feedback.ErrBadArgument)
133131
} else {
134132
logrus.SetLevel(lvl)
135133
}

‎cli/globals/globals.go

Copy file name to clipboardExpand all lines: cli/globals/globals.go
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ var (
2929
ModuleFirmwareIndexGZURL = "https://downloads.arduino.cc/arduino-fwuploader/boards/module_firmware_index.json.gz"
3030
PluginFirmwareIndexGZURL = "https://downloads.arduino.cc/arduino-fwuploader/boards/plugin_firmware_index.json.gz"
3131
FwUploaderPath = paths.TempDir().Join("fwuploader")
32+
Verbose bool
33+
LogLevel string
3234
)
3335

3436
//go:embed keys/*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.