summaryrefslogtreecommitdiff
path: root/indexers/pikdex/meta.go
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-06-01 18:47:44 +0200
committerewy <ewy0@protonmail.com>2026-06-01 18:47:44 +0200
commit46d032cd21b0e8e2c94a32333d3805ec76980cca (patch)
treefbb8aed5c5a501aca1309f62a9d4440ca949ce4c /indexers/pikdex/meta.go
parent7585a488b7b1e1812f7ebf50107139e2fd65f035 (diff)
add man(1) generation
Diffstat (limited to 'indexers/pikdex/meta.go')
-rw-r--r--indexers/pikdex/meta.go43
1 files changed, 32 insertions, 11 deletions
diff --git a/indexers/pikdex/meta.go b/indexers/pikdex/meta.go
index 750ce47..ef2c029 100644
--- a/indexers/pikdex/meta.go
+++ b/indexers/pikdex/meta.go
@@ -2,24 +2,28 @@ package pikdex
import (
"github.com/charmbracelet/lipgloss"
+ "github.com/ewy1/pik/describe"
"strings"
)
type MetaSetter func(s *SourceData, content string)
var MetaFiles = map[string]MetaSetter{
+ ".wants": func(s *SourceData, content string) {
+ s.Wants = contentLines(content)
+ },
+ ".includes": func(s *SourceData, content string) {
+ s.Includes = contentLines(content)
+ },
".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)
- }
- }
+ s.Aliases = contentLines(content)
},
".icon": func(s *SourceData, content string) {
- icon := strip(content)
+ lines := contentLines(content)
+ if len(lines) == 0 {
+ return
+ }
+ icon := lines[0]
desiredWidth := lipgloss.Width(icon)
diff := desiredWidth - len([]rune(icon))
icon += strings.Repeat(" ", diff)
@@ -27,6 +31,23 @@ var MetaFiles = map[string]MetaSetter{
},
}
-func strip(input string) string {
- return strings.TrimSpace(input)
+func contentLines(input string) []string {
+ result := make([]string, 0, len(input))
+nextLine:
+ for _, l := range strings.Split(input, "\n") {
+ l = strings.TrimSpace(l)
+
+ if l == "" {
+ continue nextLine
+ }
+
+ for _, c := range describe.CommentPrefixes {
+ if strings.HasPrefix(l, c) {
+ continue nextLine
+ }
+ }
+
+ result = append(result, l)
+ }
+ return result
}