Skip to content

Commit be4389e

Browse files
cli: lib list use feedback result structs
1 parent df2b08f commit be4389e

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

internal/cli/lib/list.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
"github.com/arduino/arduino-cli/commands/lib"
2626
"github.com/arduino/arduino-cli/internal/cli/feedback"
27+
"github.com/arduino/arduino-cli/internal/cli/feedback/result"
2728
"github.com/arduino/arduino-cli/internal/cli/instance"
2829
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2930
"github.com/arduino/arduino-cli/table"
@@ -59,9 +60,14 @@ not listed, they can be listed by adding the --all flag.`),
5960
// List gets and prints a list of installed libraries.
6061
func List(instance *rpc.Instance, args []string, all bool, updatable bool) {
6162
installedLibs := GetList(instance, args, all, updatable)
63+
64+
installedLibsResult := make([]*result.InstalledLibrary, len(installedLibs))
65+
for i, v := range installedLibs {
66+
installedLibsResult[i] = result.NewInstalledLibrary(v)
67+
}
6268
feedback.PrintResult(installedResult{
6369
onlyUpdates: updatable,
64-
installedLibs: installedLibs,
70+
installedLibs: installedLibsResult,
6571
})
6672
logrus.Info("Done")
6773
}
@@ -113,7 +119,7 @@ func GetList(
113119
// feedback.Result implementation
114120
type installedResult struct {
115121
onlyUpdates bool
116-
installedLibs []*rpc.InstalledLibrary
122+
installedLibs []*result.InstalledLibrary
117123
}
118124

119125
func (ir installedResult) Data() interface{} {
@@ -140,23 +146,26 @@ func (ir installedResult) String() string {
140146

141147
lastName := ""
142148
for _, libMeta := range ir.installedLibs {
143-
lib := libMeta.GetLibrary()
149+
if libMeta == nil {
150+
continue
151+
}
152+
lib := libMeta.Library
144153
name := lib.Name
145154
if name == lastName {
146155
name = ` "`
147156
} else {
148157
lastName = name
149158
}
150159

151-
location := lib.GetLocation().String()
160+
location := string(lib.Location)
152161
if lib.ContainerPlatform != "" {
153-
location = lib.GetContainerPlatform()
162+
location = lib.ContainerPlatform
154163
}
155164

156165
available := ""
157166
sentence := ""
158-
if libMeta.GetRelease() != nil {
159-
available = libMeta.GetRelease().GetVersion()
167+
if libMeta.Release != nil {
168+
available = libMeta.Release.Version
160169
sentence = lib.Sentence
161170
}
162171

internal/cli/outdated/outdated.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func newOutdatedResult(inPlatforms []*rpc.PlatformSummary, inLibraries []*rpc.In
7878
res.Platforms[i] = result.NewPlatformSummary(v)
7979
}
8080
for i, v := range inLibraries {
81-
res.InstalledLibs[i] = result.NewInstalledLibraryResult(v)
81+
res.InstalledLibs[i] = result.NewInstalledLibrary(v)
8282
}
8383
return res
8484
}

0 commit comments

Comments
 (0)