MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / sortTemplates

Function sortTemplates

tui/create.go:401–421  ·  view source on GitHub ↗
(templates []api.TemplateEntry)

Source from the content-addressed store, hash-verified

399}
400
401func sortTemplates(templates []api.TemplateEntry) []api.TemplateEntry {
402 var base *api.TemplateEntry
403 rest := make([]api.TemplateEntry, 0, len(templates))
404
405 for i, t := range templates {
406 if strings.EqualFold(t.Key, "base") {
407 base = &templates[i]
408 } else {
409 rest = append(rest, t)
410 }
411 }
412
413 sort.Slice(rest, func(i, j int) bool {
414 return strings.ToLower(rest[i].Template.DisplayName) < strings.ToLower(rest[j].Template.DisplayName)
415 })
416
417 if base != nil {
418 return append([]api.TemplateEntry{*base}, rest...)
419 }
420 return rest
421}
422
423func fetchCreateTemplatesCmd(client *api.Client) tea.Cmd {
424 return func() tea.Msg {

Callers 1

UpdateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected