summaryrefslogtreecommitdiff
path: root/internal/platforms
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-11-19 22:46:05 +0200
committerPaul Buetow <paul@buetow.org>2024-11-19 22:46:05 +0200
commit836d21a7c43f4ce84dfa1ada0552989be4a43ca9 (patch)
treefe6dc637c2c916e10b1beff31d687edf0f994503 /internal/platforms
parent1550fbf9c2b0602c4675f25cd92e389593894e58 (diff)
use of platform aliases
Diffstat (limited to 'internal/platforms')
-rw-r--r--internal/platforms/platform.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/platforms/platform.go b/internal/platforms/platform.go
new file mode 100644
index 0000000..f899357
--- /dev/null
+++ b/internal/platforms/platform.go
@@ -0,0 +1,32 @@
+package platforms
+
+import (
+ "fmt"
+ "strings"
+)
+
+type Platform string
+
+var aliases = map[string]string{
+ "linkedin": "linkedin",
+ "li": "linkedin",
+ "mastodon": "mastodon",
+ "ma": "mastodon",
+ "xcom": "xcom",
+ "x": "xcom",
+ "twitter": "xcom",
+ "tw": "xcom",
+}
+
+func New(platformStr string) (Platform, error) {
+ var p Platform
+ name, ok := aliases[strings.ToLower(platformStr)]
+ if !ok {
+ return p, fmt.Errorf("no such platform: '%s'", platformStr)
+ }
+ return Platform(name), nil
+}
+
+func (p Platform) String() string {
+ return string(p)
+}