Skip to content

Commit 7414838

Browse files
cli: lib examples use feedback result structs
1 parent b69f2e9 commit 7414838

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

internal/cli/lib/examples.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/arduino/arduino-cli/commands/lib"
2626
"github.com/arduino/arduino-cli/internal/cli/arguments"
2727
"github.com/arduino/arduino-cli/internal/cli/feedback"
28+
"github.com/arduino/arduino-cli/internal/cli/feedback/result"
2829
"github.com/arduino/arduino-cli/internal/cli/instance"
2930
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
3031
"github.com/arduino/go-paths-helper"
@@ -75,7 +76,7 @@ func runExamplesCommand(cmd *cobra.Command, args []string) {
7576
found := []*libraryExamples{}
7677
for _, lib := range res.GetInstalledLibraries() {
7778
found = append(found, &libraryExamples{
78-
Library: lib.Library,
79+
Library: result.NewLibrary(lib.Library),
7980
Examples: lib.Library.Examples,
8081
})
8182
}
@@ -88,8 +89,8 @@ func runExamplesCommand(cmd *cobra.Command, args []string) {
8889
// feedback.Result implementation
8990

9091
type libraryExamples struct {
91-
Library *rpc.Library `json:"library"`
92-
Examples []string `json:"examples"`
92+
Library *result.Library `json:"library"`
93+
Examples []string `json:"examples"`
9394
}
9495

9596
type libraryExamplesResult struct {
@@ -113,9 +114,9 @@ func (ir libraryExamplesResult) String() string {
113114
for _, lib := range ir.Examples {
114115
name := lib.Library.Name
115116
if lib.Library.ContainerPlatform != "" {
116-
name += " (" + lib.Library.GetContainerPlatform() + ")"
117-
} else if lib.Library.Location != rpc.LibraryLocation_LIBRARY_LOCATION_USER {
118-
name += " (" + lib.Library.GetLocation().String() + ")"
117+
name += " (" + lib.Library.ContainerPlatform + ")"
118+
} else if string(lib.Library.Location) != rpc.LibraryLocation_name[int32(rpc.LibraryLocation_LIBRARY_LOCATION_USER)] {
119+
name += " (" + string(lib.Library.Location) + ")"
119120
}
120121
r := tr("Examples for library %s", color.GreenString("%s", name)) + "\n"
121122
sort.Slice(lib.Examples, func(i, j int) bool {

0 commit comments

Comments
 (0)