65 lines
1.4 KiB
Go
65 lines
1.4 KiB
Go
/*
|
|
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"
|
|
)
|
|
|
|
// retrieved from https://statsapi.mlb.com/api/v1/sports
|
|
var sportIDs = map[string]int{
|
|
"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,
|
|
}
|
|
|
|
type sportAbbr string
|
|
|
|
func (t *sportAbbr) String() string {
|
|
return string(*t)
|
|
}
|
|
|
|
func (t *sportAbbr) Set(v string) error {
|
|
v = strings.ToLower(v)
|
|
|
|
err := validateFlag(v, sportIDs)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
*t = sportAbbr(v)
|
|
return nil
|
|
}
|
|
|
|
func (t *sportAbbr) Type() string {
|
|
return "sportAbbr"
|
|
}
|