60 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
/*
 | 
						|
Copyright © 2024,2025 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/leagues
 | 
						|
var leagueIDs = map[string]int{
 | 
						|
	"al":  103,
 | 
						|
	"nl":  104,
 | 
						|
	"nn2": 431,
 | 
						|
	"nnl": 430,
 | 
						|
	"ewl": 429,
 | 
						|
	"nal": 428,
 | 
						|
	"ecl": 427,
 | 
						|
	"anl": 426,
 | 
						|
	"nsl": 432,
 | 
						|
	"aa":  100,
 | 
						|
	"pl":  105,
 | 
						|
	"ua":  101,
 | 
						|
	"fl":  106,
 | 
						|
}
 | 
						|
 | 
						|
type leagueAbbr string
 | 
						|
 | 
						|
func (t *leagueAbbr) String() string {
 | 
						|
	return string(*t)
 | 
						|
}
 | 
						|
 | 
						|
func (t *leagueAbbr) Set(v string) error {
 | 
						|
	v = strings.ToLower(v)
 | 
						|
 | 
						|
	err := validateFlag(v, leagueIDs)
 | 
						|
	if err != nil {
 | 
						|
		return err
 | 
						|
	}
 | 
						|
 | 
						|
	*t = leagueAbbr(v)
 | 
						|
	return nil
 | 
						|
}
 | 
						|
 | 
						|
func (t *leagueAbbr) Type() string {
 | 
						|
	return "leagueAbbr"
 | 
						|
}
 |