-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* default from flag and check for missing value #fixes #1 (#11) * update measurements mini datetimes to RFC3339 formatting fixes #2 (#12) * added `--iso` flag to `locations` sub-command (#20) --------- Co-authored-by: Gabriel Fosse <kraken+majesticio@users.noreply.github.com> * add providers resource with list and get commands resolves #13 (#21) * add countries mini option resolves #7 (#23) * add proivders table output (#24) * Measurements mini csv (#25) * add proivders table output * add mini csv option for measurements resolves #22 * refactor client and include user-agent (#26) * Refactor/flags (#27) * refactor client and include user-agent * refactor flags to separate flags package resolves #19 * add radius search to locations list (#28) * add bounding box on locations (#29) --------- Co-authored-by: Gabriel Fosse <67290377+majesticio@users.noreply.github.com> Co-authored-by: Gabriel Fosse <kraken+majesticio@users.noreply.github.com>
- Loading branch information
1 parent
19a49c3
commit 3002f59
Showing
13 changed files
with
459 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package flags | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var pretty bool | ||
var json bool | ||
var csv bool | ||
var mini bool | ||
var limit int64 | ||
var page int64 | ||
var fromDate string | ||
var toDate string | ||
var periodName string | ||
var parameterType string | ||
var isoCode string | ||
var radius int64 | ||
var coordinates []float64 | ||
var bbox []float64 | ||
|
||
var countriesIDs []int64 | ||
var providersIDs []int64 | ||
var parametersIDs []int64 | ||
|
||
func AddCountries(cmd *cobra.Command) { | ||
cmd.PersistentFlags().Int64SliceVar(&countriesIDs, "countries", []int64{}, "filter results by country ID(s)") | ||
} | ||
|
||
func AddParameters(cmd *cobra.Command) { | ||
cmd.PersistentFlags().Int64SliceVar(¶metersIDs, "parameters", []int64{}, "filter results by parameters ID(s)") | ||
} | ||
|
||
func AddParametersType(cmd *cobra.Command) { | ||
cmd.PersistentFlags().StringVar(¶meterType, "type", "", "filter parameters to either `pollutants` or `meteorolgoical` parameters") | ||
} | ||
|
||
func AddProviders(cmd *cobra.Command) { | ||
cmd.PersistentFlags().Int64SliceVar(&providersIDs, "providers", []int64{}, "filter results by provider by provider ID(s)") | ||
} | ||
|
||
func AddFormat(cmd *cobra.Command) { | ||
cmd.PersistentFlags().BoolVar(&json, "json", false, "output results as JSON") | ||
cmd.PersistentFlags().BoolVar(&csv, "csv", false, "output results as CSV (Comma Separated Values)") | ||
cmd.PersistentFlags().BoolVar(&pretty, "pretty", false, "pretty print") | ||
cmd.MarkFlagsMutuallyExclusive("json", "csv") | ||
cmd.MarkFlagsMutuallyExclusive("pretty", "csv") | ||
} | ||
|
||
func AddLimit(cmd *cobra.Command) { | ||
cmd.PersistentFlags().Int64Var(&limit, "limit", 100, "limit") | ||
} | ||
|
||
func AddPage(cmd *cobra.Command) { | ||
cmd.PersistentFlags().Int64Var(&page, "page", 1, "page") | ||
} | ||
|
||
func AddFromDate(cmd *cobra.Command) { | ||
cmd.PersistentFlags().StringVar(&fromDate, "from", "2000-01-01", "from") | ||
} | ||
|
||
func AddToDate(cmd *cobra.Command) { | ||
cmd.PersistentFlags().StringVar(&toDate, "to", "", "to") | ||
} | ||
|
||
func AddPeriodName(cmd *cobra.Command) { | ||
cmd.PersistentFlags().StringVar(&periodName, "period-name", "", "period-name") | ||
} | ||
|
||
func AddMini(cmd *cobra.Command) { | ||
cmd.PersistentFlags().BoolVar(&mini, "mini", false, "mini") | ||
} | ||
|
||
func AddIsoCode(cmd *cobra.Command) { | ||
cmd.PersistentFlags().StringVar(&isoCode, "iso", "", "Limit the results to a specific country using ISO 3166-1 alpha-2 code") | ||
} | ||
|
||
func AddRadiusSearch(cmd *cobra.Command) { | ||
cmd.PersistentFlags().Int64Var(&radius, "radius", 0, "distance in meters to search around `coordinates`") | ||
cmd.PersistentFlags().Float64SliceVar(&coordinates, "coordinates", nil, "Coordinate pair of center point to perform radius search. In form latitude,longitude i.e. y,x") | ||
cmd.MarkFlagsRequiredTogether("radius", "coordinates") | ||
} | ||
|
||
func AddBBox(cmd *cobra.Command) { | ||
cmd.PersistentFlags().Float64SliceVar(&bbox, "bbox", nil, "A bounding box to search within in form minx,miny,maxx,maxy") | ||
cmd.MarkFlagsMutuallyExclusive("radius", "bbox") | ||
cmd.MarkFlagsMutuallyExclusive("coordinates", "bbox") | ||
} |
Oops, something went wrong.