@@ -24,8 +24,6 @@ import (
2424 "github.com/arduino/arduino-cli/cli/instance"
2525 "github.com/arduino/arduino-cli/cli/output"
2626 "github.com/arduino/arduino-cli/commands"
27- "github.com/arduino/arduino-cli/commands/core"
28- "github.com/arduino/arduino-cli/commands/lib"
2927 rpc "github.com/arduino/arduino-cli/rpc/commands"
3028 "github.com/arduino/arduino-cli/table"
3129 "github.com/sirupsen/logrus"
@@ -55,63 +53,41 @@ func runUpdateCommand(cmd *cobra.Command, args []string) {
5553
5654 logrus .Info ("Executing `arduino update`" )
5755
58- _ , err := commands .UpdateIndex (context .Background (), & rpc.UpdateIndexReq {
56+ err := commands .UpdateCoreLibrariesIndex (context .Background (), & rpc.UpdateCoreLibrariesIndexReq {
5957 Instance : instance ,
6058 }, output .ProgressBar ())
6159 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 )
7161 os .Exit (errorcodes .ErrGeneric )
7262 }
7363
7464 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 ,
8767 })
8868 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 )
9170 }
9271
9372 // Prints outdated cores
9473 tab := table .New ()
9574 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 )
10078 }
10179 feedback .Print (tab .Render ())
10280 }
10381
10482 // Prints outdated libraries
10583 tab = table .New ()
10684 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 {
11087 tab .AddRow (l .Library .Name , l .Library .Version , l .Release .Version )
11188 }
11289 feedback .Print (tab .Render ())
11390 }
114-
11591 }
11692
11793 logrus .Info ("Done" )
0 commit comments