Files
mlbstats/cmd/sportabbr.go

65 lines
1.4 KiB
Go
Raw Normal View History

2024-07-28 22:07:28 -05:00
/*
2025-04-06 23:06:31 -04:00
Copyright © 2024,2025 filifa
2024-07-28 22:07:28 -05:00
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"
)
2025-04-06 01:12:36 -04:00
// retrieved from https://statsapi.mlb.com/api/v1/sports
2025-04-06 22:29:56 -04:00
var sportIDs = map[string]int{
2025-04-06 01:07:57 -04:00
"mlb": 1,
"aaa": 11,
"aa": 12,
"higha": 13,
"a": 14,
"rookie": 16,
"winter": 17,
"milb": 21,
"indie": 23,
"negro": 61,
"kbo": 32,
"npb": 31,
"int": 51,
"int18u": 509,
"int16u": 510,
"intamateur": 6005,
"college": 22,
"hs": 586,
2024-07-28 22:07:28 -05:00
}
2024-07-29 00:21:51 -05:00
type sportAbbr string
2024-07-28 22:07:28 -05:00
2024-07-29 00:21:51 -05:00
func (t *sportAbbr) String() string {
2024-07-28 22:07:28 -05:00
return string(*t)
}
2024-07-29 00:21:51 -05:00
func (t *sportAbbr) Set(v string) error {
2024-07-28 22:07:28 -05:00
v = strings.ToLower(v)
2024-07-28 23:32:50 -05:00
err := validateFlag(v, sportIDs)
if err != nil {
return err
2024-07-28 22:07:28 -05:00
}
2024-07-28 23:32:50 -05:00
2024-07-29 00:21:51 -05:00
*t = sportAbbr(v)
2024-07-28 23:32:50 -05:00
return nil
2024-07-28 22:07:28 -05:00
}
2024-07-29 00:21:51 -05:00
func (t *sportAbbr) Type() string {
return "sportAbbr"
2024-07-28 22:07:28 -05:00
}