@@ -24,8 +24,6 @@ import (
24
24
"github.com/arduino/arduino-cli/cli/instance"
25
25
"github.com/arduino/arduino-cli/cli/output"
26
26
"github.com/arduino/arduino-cli/commands"
27
- "github.com/arduino/arduino-cli/commands/core"
28
- "github.com/arduino/arduino-cli/commands/lib"
29
27
rpc "github.com/arduino/arduino-cli/rpc/commands"
30
28
"github.com/arduino/arduino-cli/table"
31
29
"github.com/sirupsen/logrus"
@@ -55,63 +53,41 @@ func runUpdateCommand(cmd *cobra.Command, args []string) {
55
53
56
54
logrus .Info ("Executing `arduino update`" )
57
55
58
- _ , err := commands .UpdateIndex (context .Background (), & rpc.UpdateIndexReq {
56
+ err := commands .UpdateCoreLibrariesIndex (context .Background (), & rpc.UpdateCoreLibrariesIndexReq {
59
57
Instance : instance ,
60
58
}, output .ProgressBar ())
61
59
if err != nil {
62
- feedback .Errorf ("Error updating core index: %v" , err )
63
- os .Exit (errorcodes .ErrGeneric )
64
- }
65
-
66
- err = commands .UpdateLibrariesIndex (context .Background (), & rpc.UpdateLibrariesIndexReq {
67
- Instance : instance ,
68
- }, output .ProgressBar ())
69
- if err != nil {
70
- feedback .Errorf ("Error updating library index: %v" , err )
60
+ feedback .Errorf ("Error updating core and libraries index: %v" , err )
71
61
os .Exit (errorcodes .ErrGeneric )
72
62
}
73
63
74
64
if updateFlags .showOutdated {
75
- // Gets outdated cores
76
- targets , err := core .GetPlatforms (instance .Id , true )
77
- if err != nil {
78
- feedback .Errorf ("Error retrieving core list: %v" , err )
79
- os .Exit (errorcodes .ErrGeneric )
80
- }
81
-
82
- // Gets outdated libraries
83
- res , err := lib .LibraryList (context .Background (), & rpc.LibraryListReq {
84
- Instance : instance ,
85
- All : false ,
86
- Updatable : true ,
65
+ outdatedResp , err := commands .Outdated (context .Background (), & rpc.OutdatedReq {
66
+ Instance : instance ,
87
67
})
88
68
if err != nil {
89
- feedback .Errorf ("Error retrieving library list: %v" , err )
90
- os .Exit (errorcodes .ErrGeneric )
69
+ feedback .Errorf ("Error retrieving outdated cores and libraries: %v" , err )
91
70
}
92
71
93
72
// Prints outdated cores
94
73
tab := table .New ()
95
74
tab .SetHeader ("Core name" , "Installed version" , "New version" )
96
- if len (targets ) > 0 {
97
- for _ , t := range targets {
98
- plat := t .Platform
99
- tab .AddRow (plat .Name , t .Version , plat .GetLatestRelease ().Version )
75
+ if len (outdatedResp .OutdatedPlatform ) > 0 {
76
+ for _ , p := range outdatedResp .OutdatedPlatform {
77
+ tab .AddRow (p .Name , p .Installed , p .Latest )
100
78
}
101
79
feedback .Print (tab .Render ())
102
80
}
103
81
104
82
// Prints outdated libraries
105
83
tab = table .New ()
106
84
tab .SetHeader ("Library name" , "Installed version" , "New version" )
107
- libs := res .GetInstalledLibrary ()
108
- if len (libs ) > 0 {
109
- for _ , l := range libs {
85
+ if len (outdatedResp .OutdatedLibrary ) > 0 {
86
+ for _ , l := range outdatedResp .OutdatedLibrary {
110
87
tab .AddRow (l .Library .Name , l .Library .Version , l .Release .Version )
111
88
}
112
89
feedback .Print (tab .Render ())
113
90
}
114
-
115
91
}
116
92
117
93
logrus .Info ("Done" )
0 commit comments