Skip to content

Commit

Permalink
perf(profiles): Optimize profile template loading
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Feb 13, 2025
1 parent c6fd890 commit f40889a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/profiles/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,23 @@ func helpFunc(cmd *cobra.Command, _ []string) {
style.Color.Border = text.Colors{text.FgHiBlack}
style.Color.Separator = style.Color.Border
t.SetStyle(style)
t.AppendHeader(table.Row{"Name", "Example", "Template"})

profiles := config.New().Profiles.Named()
slices.SortStableFunc(profiles, func(a, b config.NamedProfile) int {
return cmp.Compare(a.Name, b.Name)
})

words := wordlist.EFF_Long()
tmpl := template.New("").Funcs(funcmap.New(words))

t.AppendHeader(table.Row{"Name", "Example", "Template"})
for _, v := range profiles {
name := v.Name
if v.Param != 0 {
name += ":" + strconv.Itoa(v.Param)
}

var buf strings.Builder
tmpl, err := template.New("").Funcs(funcmap.New(words)).Parse(v.Template)
tmpl, err := tmpl.New("").Parse(v.Template)
if err == nil {
_ = tmpl.Execute(&buf, v.Param)
}
Expand Down

0 comments on commit f40889a

Please sign in to comment.