diff options
Diffstat (limited to 'indexers/pikdex')
| -rw-r--r-- | indexers/pikdex/index.go | 4 | ||||
| -rw-r--r-- | indexers/pikdex/meta.go | 33 |
2 files changed, 21 insertions, 16 deletions
diff --git a/indexers/pikdex/index.go b/indexers/pikdex/index.go index 1979e4d..4dd1d36 100644 --- a/indexers/pikdex/index.go +++ b/indexers/pikdex/index.go @@ -73,10 +73,10 @@ func (u *pikdex) Index(absPath string, f fs.FS, runners []model.Runner) ([]model content, err := os.ReadFile(expectedLocation) if err != nil { - spool.Warn("%v\n", err) + _, _ = spool.Warn("%v\n", err) continue } - applier(mod, string(content)) + applier.MetaSetter(mod, string(content)) } } diff --git a/indexers/pikdex/meta.go b/indexers/pikdex/meta.go index 777df51..3eb182f 100644 --- a/indexers/pikdex/meta.go +++ b/indexers/pikdex/meta.go @@ -9,33 +9,38 @@ import ( type MetaSetter func(s *model.SourceData, content string) -var MetaFiles = map[string]MetaSetter{ - ".want": func(s *model.SourceData, content string) { +type MetaFile struct { + MetaSetter + Description string +} + +var MetaFiles = map[string]*MetaFile{ + ".want": {MetaSetter: func(s *model.SourceData, content string) { s.Wants = append(s.Wants, contentLines(content)...) - }, - ".wants": func(s *model.SourceData, content string) { + }, Description: "want[s] adds external sources to your pik state. Currently only local paths are supported, one per line. For example, including '../web' will ensure that folder will be included and callable in the pik state without having to provide the --all flag."}, + ".wants": {MetaSetter: func(s *model.SourceData, content string) { s.Wants = append(s.Wants, contentLines(content)...) - }, - ".include": func(s *model.SourceData, content string) { + }}, + ".include": {MetaSetter: func(s *model.SourceData, content string) { s.Includes = append(s.Includes, contentLines(content)...) - }, - ".includes": func(s *model.SourceData, content string) { + }, Description: "include[s] adds items from external sources to this pik source. For example, adding '../shared' will add all targets from there to this source. Triggers from the included source will work, and all targets will be ran as if they were part of the including source."}, + ".includes": {MetaSetter: func(s *model.SourceData, content string) { s.Includes = append(s.Includes, contentLines(content)...) - }, - ".alias": func(s *model.SourceData, content string) { + }}, + ".alias": {MetaSetter: func(s *model.SourceData, content string) { s.Aliases = contentLines(content) - }, - ".icon": func(s *model.SourceData, content string) { + }, Description: "alias can contain multiple lines with alternate names for this source. The first non-comment line will be used as the display name. You can use this for, for example, abbreviations."}, + ".icon": {MetaSetter: func(s *model.SourceData, content string) { lines := contentLines(content) if len(lines) == 0 { return } - icon := lines[0] + icon := string([]rune(lines[0])[:2]) desiredWidth := lipgloss.Width(icon) diff := desiredWidth - len([]rune(icon)) icon += strings.Repeat(" ", diff) s.Icon = icon - }, + }, Description: "icon can contain unicode symbols representing your source. It will be used in the TUI. It will be cropped to maximum two symbols and padded if shorter."}, } func contentLines(input string) []string { |
