Skip to content

Commit 14d7e3d

Browse files
committed
add description completion suggestion for core, lib, fqbn, programmer
1 parent 3e2de29 commit 14d7e3d

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

cli/arguments/completion.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ func GetInstalledBoards(toComplete string) []string {
2525
})
2626
var res []string
2727
// transform the data structure for the completion
28-
for _, i := range list.GetBoards() {
29-
res = append(res, i.Fqbn)
28+
for _, i := range list.Boards {
29+
res = append(res, i.Fqbn+"\t"+i.Name)
3030
}
3131
return res
3232
}
@@ -71,21 +71,19 @@ func GetInstalledProgrammers(toComplete string) []string {
7171
IncludeHiddenBoards: false,
7272
})
7373

74-
// use this strange map because it should be more optimized
75-
// we use only the key and not the value because we do not need it
76-
installedProgrammers := make(map[string]struct{})
77-
for _, i := range list.GetBoards() {
74+
installedProgrammers := make(map[string]string)
75+
for _, i := range list.Boards {
7876
fqbn, _ := cores.ParseFQBN(i.Fqbn)
7977
_, boardPlatform, _, _, _, _ := pm.ResolveFQBN(fqbn)
80-
for programmerID := range boardPlatform.Programmers {
81-
installedProgrammers[programmerID] = struct{}{}
78+
for programmerID, programmer := range boardPlatform.Programmers {
79+
installedProgrammers[programmerID] = programmer.Name
8280
}
8381
}
8482

8583
res := make([]string, len(installedProgrammers))
8684
i := 0
87-
for k := range installedProgrammers {
88-
res[i] = k
85+
for programmerID := range installedProgrammers {
86+
res[i] = programmerID + "\t" + installedProgrammers[programmerID]
8987
i++
9088
}
9189
return res
@@ -104,7 +102,7 @@ func GetUninstallableCores(toComplete string) []string {
104102
var res []string
105103
// transform the data structure for the completion
106104
for _, i := range platforms {
107-
res = append(res, i.GetId())
105+
res = append(res, i.Id+"\t"+i.Name)
108106
}
109107
return res
110108
}
@@ -122,7 +120,7 @@ func GetInstallableCores(toComplete string) []string {
122120
var res []string
123121
// transform the data structure for the completion
124122
for _, i := range platforms.SearchOutput {
125-
res = append(res, i.GetId())
123+
res = append(res, i.Id+"\t"+i.Name)
126124
}
127125
return res
128126
}
@@ -141,7 +139,7 @@ func GetUninstallableLibs(toComplete string) []string {
141139
var res []string
142140
// transform the data structure for the completion
143141
for _, i := range libs.InstalledLibraries {
144-
res = append(res, i.GetLibrary().Name)
142+
res = append(res, i.Library.Name+"\t"+i.Library.Sentence)
145143
}
146144
return res
147145
}
@@ -158,7 +156,7 @@ func GetInstallableLibs(toComplete string) []string {
158156
var res []string
159157
// transform the data structure for the completion
160158
for _, i := range libs.Libraries {
161-
res = append(res, i.Name)
159+
res = append(res, i.Name+"\t"+i.Latest.Sentence)
162160
}
163161
return res
164162
}

0 commit comments

Comments
 (0)