about summary refs log tree commit diff stats
path: root/internal/config
diff options
context:
space:
mode:
authorAlan Pearce2024-06-21 15:35:23 +0200
committerAlan Pearce2024-06-21 15:44:12 +0200
commit58a7fc78b8e17dc4ce009767afd9066bbaa9328f (patch)
treee5d4c12584f22d7718aea87540e4e437f1b47528 /internal/config
parenta1dfc548198a1326e71f1dd70303a5d3441f7a39 (diff)
downloadsearchix-58a7fc78b8e17dc4ce009767afd9066bbaa9328f.tar.lz
searchix-58a7fc78b8e17dc4ce009767afd9066bbaa9328f.tar.zst
searchix-58a7fc78b8e17dc4ce009767afd9066bbaa9328f.zip
refactor: use encoding/xml for OpenSearchDescription
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/config.go12
-rw-r--r--internal/config/structs.go12
2 files changed, 24 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 83ddd2c..14375d6 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -31,6 +31,18 @@ func (u *URL) UnmarshalText(text []byte) (err error) {
 	return nil
 }
 
+func (u *URL) JoinPath(elems ...string) *URL {
+	return &URL{u.URL.JoinPath(elems...)}
+}
+
+func (u *URL) AddQuery(key, value string) *URL {
+	q := u.URL.Query()
+	q.Add(key, value)
+	u.RawQuery = q.Encode()
+
+	return u
+}
+
 type Duration struct {
 	time.Duration
 }
diff --git a/internal/config/structs.go b/internal/config/structs.go
index 6c6bc13..e6cf20b 100644
--- a/internal/config/structs.go
+++ b/internal/config/structs.go
@@ -4,6 +4,7 @@ package config
 // keep config structs here so that lll ignores the long lines (go doesn't support multi-line struct tags)
 
 import (
+	"fmt"
 	"log/slog"
 )
 
@@ -47,3 +48,14 @@ type Source struct {
 	OutputPath string       `comment:"(Fetcher=channel) Path under ./result symlink to folder containing {options,packages}.json."`
 	Repo       Repository   `comment:"Used to generate declaration/definition links"`
 }
+
+func (source *Source) String() string {
+	switch source.Importer {
+	case Options:
+		return source.Name + " " + source.Importer.String()
+	case Packages:
+		return source.Name
+	default:
+		return fmt.Sprintf("Source(%s)", source.Name)
+	}
+}