From b1ad24cd30a19d110b3355a08a7b2a5dba51138d Mon Sep 17 00:00:00 2001 From: Max Helmetag Date: Wed, 27 Jun 2018 21:06:25 -0700 Subject: [PATCH] update gosurf sample config, update valid days check --- .gosurf.sample.yml | 2 +- README.md | 2 -- main.go | 16 ++++++---------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.gosurf.sample.yml b/.gosurf.sample.yml index c85e88a..2492788 100644 --- a/.gosurf.sample.yml +++ b/.gosurf.sample.yml @@ -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 diff --git a/README.md b/README.md index 4f5dbcf..05eb9df 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,6 @@ $ gosurf --a 4710 p --pt regions +------+-------------+ ``` - - ### Forecasts To get a forecast (the default subregion is Santa Barbara, CA, USA): diff --git a/main.go b/main.go index f054534..707a351 100644 --- a/main.go +++ b/main.go @@ -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, }, ), @@ -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 } @@ -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"}) @@ -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 }