diff options
Diffstat (limited to 'internal/config/args.go')
| -rw-r--r-- | internal/config/args.go | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/internal/config/args.go b/internal/config/args.go index d1d8fe8..215c634 100644 --- a/internal/config/args.go +++ b/internal/config/args.go @@ -1,23 +1,18 @@ package config import ( - "fmt" - "slices" "strconv" "strings" "time" "codeberg.org/snonux/gos/internal/colour" - "codeberg.org/snonux/gos/internal/platforms" ) -var validPlatforms = []string{"mastodon", "linkedin"} - type Args struct { GosDir string CacheDir string DryRun bool - Platforms map[platforms.Platform]int // Platform and post size limits + Platforms map[string]int // Platform and post size limits Target int MinQueued int MaxDaysQueued int @@ -29,34 +24,23 @@ type Args struct { } func (a *Args) ParsePlatforms(platformStrs string) error { - a.Platforms = make(map[platforms.Platform]int) + a.Platforms = make(map[string]int) - for _, platformStr := range strings.Split(platformStrs, ",") { + for _, platformInfo := range strings.Split(platformStrs, ",") { // E.g. Mastodon:500 - parts := strings.Split(platformStr, ":") - platform, err := platforms.New(parts[0]) - if err != nil { - return err - } + parts := strings.Split(platformInfo, ":") + platformStr := parts[0] // E.g. args.Platform["mastodon"] = 500 if len(parts) > 1 { - a.Platforms[platform], err = strconv.Atoi(parts[1]) + var err error + a.Platforms[platformStr], err = strconv.Atoi(parts[1]) if err != nil { return err } } else { - colour.Infoln("No message length specified for", platform, "so assuming 500") - a.Platforms[platform] = 500 - } - } - return nil -} - -func (a *Args) Validate() error { - for platform := range a.Platforms { - if !slices.Contains(validPlatforms, platform.String()) { - return fmt.Errorf("Platform %s not supported", platform) + colour.Infoln("No message length specified for", platformStr, "so assuming 500") + a.Platforms[platformStr] = 500 } } return nil |
