mlblive/cmd/sportabbr.go

66 lines
1.7 KiB
Go
Raw Normal View History

2024-07-29 03:07:28 +00:00
/*
Copyright © 2024 filifa
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cmd
import (
"strings"
"scm.dairydemon.net/filifa/mlblive/cmd/internal/statsapi"
)
var sportIDs = map[string]statsapi.SportID{
"mlb": statsapi.MLB,
"aaa": statsapi.TripleA,
"aa": statsapi.DoubleA,
"higha": statsapi.HighA,
"a": statsapi.SingleA,
"rookie": statsapi.Rookie,
"winter": statsapi.Winter,
"milb": statsapi.MILB,
"indie": statsapi.Independent,
"negro": statsapi.Negro,
"kbo": statsapi.Korea,
"npb": statsapi.NPB,
"int": statsapi.International,
"int18u": statsapi.International18U,
"int16u": statsapi.International16U,
"intamateur": statsapi.InternationalAmateur,
"college": statsapi.College,
"hs": statsapi.HighSchool,
}
2024-07-29 05:21:51 +00:00
type sportAbbr string
2024-07-29 03:07:28 +00:00
2024-07-29 05:21:51 +00:00
func (t *sportAbbr) String() string {
2024-07-29 03:07:28 +00:00
return string(*t)
}
2024-07-29 05:21:51 +00:00
func (t *sportAbbr) Set(v string) error {
2024-07-29 03:07:28 +00:00
v = strings.ToLower(v)
2024-07-29 04:32:50 +00:00
err := validateFlag(v, sportIDs)
if err != nil {
return err
2024-07-29 03:07:28 +00:00
}
2024-07-29 04:32:50 +00:00
2024-07-29 05:21:51 +00:00
*t = sportAbbr(v)
2024-07-29 04:32:50 +00:00
return nil
2024-07-29 03:07:28 +00:00
}
2024-07-29 05:21:51 +00:00
func (t *sportAbbr) Type() string {
return "sportAbbr"
2024-07-29 03:07:28 +00:00
}