Skip to content

Commit

Permalink
update gosurf sample config, update valid days check
Browse files Browse the repository at this point in the history
  • Loading branch information
mhelmetag committed Jun 28, 2018
1 parent 1ed4abb commit b1ad24c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gosurf.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
area: "4716" # North America
region: "2081" # Southern California
subregion: "2953" # South San Diego
days: 10 # Fetch 10 days of data for forecast, tide, etc
days: 5 # Fetch 5 days of data for forecast, tide, etc
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ $ gosurf --a 4710 p --pt regions
+------+-------------+
```



### Forecasts

To get a forecast (the default subregion is Santa Barbara, CA, USA):
Expand Down
16 changes: 6 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func main() {
Name: "days",
Aliases: []string{"d"},
Value: 7,
Usage: "number of days to report (between 1 and 15)",
Usage: "number of days to report (between 1 and 8)",
Destination: &d,
},
),
Expand Down Expand Up @@ -205,7 +205,7 @@ func tide(aID string, rID string, srID string, d int) {
}

if !validDayAmount(d) {
fmt.Println("The number of days to report can only be between 1 and 15")
fmt.Println("The number of days to report can only be between 1 and 8")

return
}
Expand Down Expand Up @@ -330,7 +330,6 @@ func analysisReports(a surflinef.Analysis) []string {
return rs
}

// use merging on date https://github.com/olekukonko/tablewriter#example-6----identical-cells-merging
func tideToTable(t surflinef.Tide) {
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Date", "Time", "Description", "Height"})
Expand Down Expand Up @@ -377,11 +376,8 @@ func validPoint(p surflinef.DataPoint) bool {
}

func validDayAmount(d int) bool {
if d < 1 {
return false
} else if d > 15 {
return false
} else {
return true
}
// I'd like to support more days (it can be up to 17)
// but I have to update SurflineF to hardcode the query param
// "callback" which seems to allow more than 8 days
return d > 1 || d < 8
}

0 comments on commit b1ad24c

Please sign in to comment.