blob: 750ce47bb512076d2e2d67f060fcd7de7e71f512 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package pikdex
import (
"github.com/charmbracelet/lipgloss"
"strings"
)
type MetaSetter func(s *SourceData, content string)
var MetaFiles = map[string]MetaSetter{
".alias": func(s *SourceData, content string) {
split := strings.Split(content, "\n")
s.Aliases = make([]string, 0, len(split))
for _, line := range split {
stripped := strip(line)
if stripped != "" {
s.Aliases = append(s.Aliases, stripped)
}
}
},
".icon": func(s *SourceData, content string) {
icon := strip(content)
desiredWidth := lipgloss.Width(icon)
diff := desiredWidth - len([]rune(icon))
icon += strings.Repeat(" ", diff)
s.Icon = icon
},
}
func strip(input string) string {
return strings.TrimSpace(input)
}
|