use teamids map
This commit is contained in:
parent
ca87734314
commit
8be2e5de9e
|
@ -1,6 +1,10 @@
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import "errors"
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"scm.dairydemon.net/filifa/mlblive/cmd/internal/statsapi"
|
||||||
|
)
|
||||||
|
|
||||||
type TeamFlag string
|
type TeamFlag string
|
||||||
|
|
||||||
|
@ -9,13 +13,14 @@ func (t *TeamFlag) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TeamFlag) Set(v string) error {
|
func (t *TeamFlag) Set(v string) error {
|
||||||
switch v {
|
var err error
|
||||||
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":
|
_, ok := statsapi.TeamIds[v]
|
||||||
|
if !ok {
|
||||||
|
err = errors.New("invalid team ID")
|
||||||
|
} else {
|
||||||
*t = TeamFlag(v)
|
*t = TeamFlag(v)
|
||||||
return nil
|
|
||||||
default:
|
|
||||||
return errors.New("invalid team ID")
|
|
||||||
}
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TeamFlag) Type() string {
|
func (t *TeamFlag) Type() string {
|
||||||
|
|
Loading…
Reference in New Issue