use teamids map
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
package cmd
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"scm.dairydemon.net/filifa/mlblive/cmd/internal/statsapi"
|
||||
)
|
||||
|
||||
type TeamFlag string
|
||||
|
||||
@@ -9,13 +13,14 @@ func (t *TeamFlag) String() string {
|
||||
}
|
||||
|
||||
func (t *TeamFlag) Set(v string) error {
|
||||
switch v {
|
||||
case "laa", "az", "bal", "bos", "chc", "cin", "cle", "col", "det", "hou", "kc", "lad", "wsh", "nym", "oak", "pit", "sd", "sea", "sf", "stl", "tb", "tex", "tor", "min", "phi", "atl", "cws", "mia", "nyy", "mil":
|
||||
var err error
|
||||
_, ok := statsapi.TeamIds[v]
|
||||
if !ok {
|
||||
err = errors.New("invalid team ID")
|
||||
} else {
|
||||
*t = TeamFlag(v)
|
||||
return nil
|
||||
default:
|
||||
return errors.New("invalid team ID")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (t *TeamFlag) Type() string {
|
||||
|
||||
Reference in New Issue
Block a user