Skip to content

Commit

Permalink
add position flag
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusfm committed Jan 19, 2022
1 parent 73ae90c commit ab61980
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 37 deletions.
3 changes: 3 additions & 0 deletions cmd/players.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
flagClubID int
flagNationID int
flagLeagueID int
flagPosition []string
flagPrice string
flagWeakFoot string
flagSkills string
Expand Down Expand Up @@ -81,6 +82,7 @@ var playersCmd = &cobra.Command{
ClubID: flagClubID,
NationID: flagNationID,
LeagueID: flagLeagueID,
Position: flagPosition,
Price: flagToRange(flagPrice),
WeakFoot: flagToRange(flagWeakFoot),
Skills: flagToRange(flagSkills),
Expand Down Expand Up @@ -136,6 +138,7 @@ func init() {
playersCmd.PersistentFlags().StringVar(&flagSkills, "skills", "", "Skills")
playersCmd.PersistentFlags().StringVar(&flagRating, "ovr", "", "Rating")
playersCmd.PersistentFlags().StringVar(&flagPrice, "price", "", "Price")
playersCmd.PersistentFlags().StringSliceVar(&flagPosition, "position", []string{}, "Position")
playersCmd.PersistentFlags().StringVar(&flagPace, "pace", "", "Pace")
playersCmd.PersistentFlags().StringVar(&flagAcceleration, "acceleration", "", "Acceleration")
playersCmd.PersistentFlags().StringVar(&flagSprintSpeed, "sprint-speed", "", "Sprint Speed")
Expand Down
21 changes: 21 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,24 @@ require (
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.9.0
)

require (
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect
golang.org/x/text v0.3.6 // indirect
gopkg.in/ini.v1 v1.63.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
2 changes: 1 addition & 1 deletion players/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Options struct {

Version string

Position []Position
Position []string
NationID int
LeagueID int
ClubID int
Expand Down
36 changes: 17 additions & 19 deletions players/position.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
package players

const (
GK Position = "GK"
RB Position = "RB"
RWB Position = "RWB"
LB Position = "LB"
LWB Position = "LWB"
CB Position = "CB"
CDM Position = "CDM"
CM Position = "CM"
CAM Position = "CAM"
RM Position = "RM"
RW Position = "RW"
RF Position = "RF"
LM Position = "LM"
LW Position = "LW"
LF Position = "LF"
CF Position = "CF"
ST Position = "ST"
PositionGK = "GK"
PositionRB = "RB"
PositionRWB = "RWB"
PositionLB = "LB"
PositionLWB = "LWB"
PositionCB = "CB"
PositionCDM = "CDM"
PositionCM = "CM"
PositionCAM = "CAM"
PositionRM = "RM"
PositionRW = "RW"
PositionRF = "RF"
PositionLM = "LM"
PositionLW = "LW"
PositionLF = "LF"
PositionCF = "CF"
PositionST = "ST"
)

type Position string
34 changes: 17 additions & 17 deletions players/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ type playerQuery struct {

Version string `url:"version,omitempty"`

Position []Position `url:"position,omitempty"`
NationID int `url:"nation,omitempty"`
LeagueID int `url:"league,omitempty"`
ClubID int `url:"club,omitempty"`
WeakFoot int `url:"wf,omitempty"`
MinWeakFoot int `url:"min_wf,omitempty"`
MaxWeakFoot int `url:"max_wf,omitempty"`
Skills int `url:"skills,omitempty"`
MinSkills int `url:"min_skills,omitempty"`
MaxSkills int `url:"max_skills,omitempty"`
Foot Foot `url:"foot,omitempty"`
PsPrice string `url:"ps4price,omitempty"`
XboxPrice string `url:"xb1price,omitempty"`
PcPrice string `url:"pcprice,omitempty"`
Rating string `url:"rating,omitempty"`
Height string `url:"height,omitempty"`
Weight string `url:"weight,omitempty"`
Position []string `url:"position,comma,omitempty"`
NationID int `url:"nation,omitempty"`
LeagueID int `url:"league,omitempty"`
ClubID int `url:"club,omitempty"`
WeakFoot int `url:"wf,omitempty"`
MinWeakFoot int `url:"min_wf,omitempty"`
MaxWeakFoot int `url:"max_wf,omitempty"`
Skills int `url:"skills,omitempty"`
MinSkills int `url:"min_skills,omitempty"`
MaxSkills int `url:"max_skills,omitempty"`
Foot Foot `url:"foot,omitempty"`
PsPrice string `url:"ps4price,omitempty"`
XboxPrice string `url:"xb1price,omitempty"`
PcPrice string `url:"pcprice,omitempty"`
Rating string `url:"rating,omitempty"`
Height string `url:"height,omitempty"`
Weight string `url:"weight,omitempty"`

Pace string `url:"Pace,omitempty"`
Acceleration string `url:"Acceleration,omitempty"`
Expand Down

0 comments on commit ab61980

Please sign in to comment.