File tree 1 file changed +21
-2
lines changed
1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,26 @@ func runSearchCommand(cmd *cobra.Command, args []string) {
65
65
}
66
66
67
67
if globals .OutputFormat == "json" {
68
- feedback .PrintJSON (searchResp )
68
+ if searchFlags .namesOnly {
69
+ type LibName struct {
70
+ Name string `json:"name,required"`
71
+ }
72
+
73
+ type NamesOnly struct {
74
+ Libraries []LibName `json:"libraries,required"`
75
+ }
76
+
77
+ names := []LibName {}
78
+ results := searchResp .GetLibraries ()
79
+ for _ , lsr := range results {
80
+ names = append (names , LibName {lsr .Name })
81
+ }
82
+ feedback .PrintJSON (NamesOnly {
83
+ names ,
84
+ })
85
+ } else {
86
+ feedback .PrintJSON (searchResp )
87
+ }
69
88
} else {
70
89
// get a sorted slice of results
71
90
results := searchResp .GetLibraries ()
@@ -87,7 +106,7 @@ func outputSearchedLibrary(results []*rpc.SearchedLibrary, namesOnly bool) {
87
106
}
88
107
89
108
for _ , lsr := range results {
90
- feedback .Printf (" Name: '%s'" , lsr .Name )
109
+ feedback .Printf (` Name: "%s"` , lsr .Name )
91
110
if namesOnly {
92
111
continue
93
112
}
You can’t perform that action at this time.
0 commit comments