diff options
Diffstat (limited to 'internal/platforms')
| -rw-r--r-- | internal/platforms/platform.go | 32 |
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) +} |
