Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
9585728e
Commit
9585728e
authored
May 06, 2024
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show config-load warning after feedback package initialization
parent
a58c3506
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
main.go
main.go
+13
-3
No files found.
main.go
View file @
9585728e
...
...
@@ -30,6 +30,7 @@ import (
rpc
"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/go-paths-helper"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func
main
()
{
...
...
@@ -45,6 +46,7 @@ func main() {
// Read the settings from the configuration file
openReq
:=
&
rpc
.
ConfigurationOpenRequest
{
SettingsFormat
:
"yaml"
}
var
configFileLoadingWarnings
[]
string
if
configData
,
err
:=
paths
.
New
(
configFile
)
.
ReadFile
();
err
==
nil
{
openReq
.
EncodedSettings
=
string
(
configData
)
}
else
if
!
os
.
IsNotExist
(
err
)
{
...
...
@@ -53,9 +55,8 @@ func main() {
if
resp
,
err
:=
srv
.
ConfigurationOpen
(
ctx
,
openReq
);
err
!=
nil
{
feedback
.
FatalError
(
fmt
.
Errorf
(
"couldn't load configuration: %w"
,
err
),
feedback
.
ErrGeneric
)
}
else
if
warnings
:=
resp
.
GetWarnings
();
len
(
warnings
)
>
0
{
for
_
,
warning
:=
range
warnings
{
feedback
.
Warning
(
warning
)
}
// Save the warnings to show them later when the feedback package is fully initialized
configFileLoadingWarnings
=
warnings
}
// Get the current settings from the server
...
...
@@ -70,6 +71,15 @@ func main() {
// Setup command line parser with the server and settings
arduinoCmd
:=
cli
.
NewCommand
(
srv
)
parentPreRun
:=
arduinoCmd
.
PersistentPreRun
arduinoCmd
.
PersistentPreRun
=
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
parentPreRun
!=
nil
{
parentPreRun
(
cmd
,
args
)
}
for
_
,
warning
:=
range
configFileLoadingWarnings
{
feedback
.
Warning
(
warning
)
}
}
// Execute the command line
if
err
:=
arduinoCmd
.
ExecuteContext
(
ctx
);
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment