use sport abbrevs instead of ids
This commit is contained in:
@@ -25,9 +25,9 @@ import (
|
|||||||
"scm.dairydemon.net/filifa/mlblive/cmd/internal/statsapi"
|
"scm.dairydemon.net/filifa/mlblive/cmd/internal/statsapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
var team teamFlag
|
|
||||||
var date string
|
var date string
|
||||||
var sportId int
|
|
||||||
|
var team teamFlag
|
||||||
var teamIDs = map[string]statsapi.TeamID{
|
var teamIDs = map[string]statsapi.TeamID{
|
||||||
"laa": statsapi.LAA,
|
"laa": statsapi.LAA,
|
||||||
"az": statsapi.AZ,
|
"az": statsapi.AZ,
|
||||||
@@ -61,15 +61,44 @@ var teamIDs = map[string]statsapi.TeamID{
|
|||||||
"mil": statsapi.MIL,
|
"mil": statsapi.MIL,
|
||||||
}
|
}
|
||||||
|
|
||||||
func schedule(cmd *cobra.Command, args []string) {
|
var sport string
|
||||||
var id string
|
var sportIDs = map[string]statsapi.SportID{
|
||||||
if team == "" {
|
"mlb": statsapi.MLB,
|
||||||
id = string(team)
|
"aaa": statsapi.AAA,
|
||||||
} else {
|
"aa": statsapi.AA,
|
||||||
id = strconv.Itoa(int(teamIDs[string(team)]))
|
"higha": statsapi.HighA,
|
||||||
|
"a": statsapi.A,
|
||||||
|
"rookie": statsapi.Rookie,
|
||||||
|
"winter": statsapi.Winter,
|
||||||
|
"milb": statsapi.MILB,
|
||||||
|
"indie": statsapi.Independent,
|
||||||
|
"negro": statsapi.Negro,
|
||||||
|
"kbo": statsapi.KBO,
|
||||||
|
"npb": statsapi.NPB,
|
||||||
|
"int": statsapi.International,
|
||||||
|
"int18u": statsapi.International18U,
|
||||||
|
"int16u": statsapi.International16U,
|
||||||
|
"intamateur": statsapi.InternationalAmateur,
|
||||||
|
"college": statsapi.College,
|
||||||
|
"hs": statsapi.HighSchool,
|
||||||
}
|
}
|
||||||
|
|
||||||
sched, err := statsapi.RequestSchedule(strconv.Itoa(sportId), id, date)
|
func schedule(cmd *cobra.Command, args []string) {
|
||||||
|
var teamId string
|
||||||
|
if team == "" {
|
||||||
|
teamId = string(team)
|
||||||
|
} else {
|
||||||
|
teamId = strconv.Itoa(int(teamIDs[string(team)]))
|
||||||
|
}
|
||||||
|
|
||||||
|
var sportId string
|
||||||
|
if sport == "" {
|
||||||
|
sportId = string(sport)
|
||||||
|
} else {
|
||||||
|
sportId = strconv.Itoa(int(sportIDs[sport]))
|
||||||
|
}
|
||||||
|
|
||||||
|
sched, err := statsapi.RequestSchedule(sportId, teamId, date)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -99,5 +128,5 @@ func init() {
|
|||||||
// is called directly, e.g.:
|
// is called directly, e.g.:
|
||||||
scheduleCmd.Flags().VarP(&team, "team", "t", "team to get schedule for (atl, az, bal, bos, chc, cin, cle, col, cws, det, hou, kc, laa, lad, mia, mil, min, nym, nyy, oak, phi, pit, sd, sea, sf, stl, tb, tex, tor, wsh)")
|
scheduleCmd.Flags().VarP(&team, "team", "t", "team to get schedule for (atl, az, bal, bos, chc, cin, cle, col, cws, det, hou, kc, laa, lad, mia, mil, min, nym, nyy, oak, phi, pit, sd, sea, sf, stl, tb, tex, tor, wsh)")
|
||||||
scheduleCmd.Flags().StringVarP(&date, "date", "d", "", "date to get schedule for (YYYY-MM-DD)")
|
scheduleCmd.Flags().StringVarP(&date, "date", "d", "", "date to get schedule for (YYYY-MM-DD)")
|
||||||
scheduleCmd.Flags().IntVarP(&sportId, "sport", "s", 1, "sport ID get schedule for (default: 1 (MLB))")
|
scheduleCmd.Flags().StringVarP(&sport, "sport", "s", "mlb", "sport to get schedule for (default: MLB)")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user