|
| 1 | +package cmd |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/openanno/bget/api/fetch" |
| 5 | + "github.com/openanno/bget/api/types" |
| 6 | + "github.com/spf13/cobra" |
| 7 | +) |
| 8 | + |
| 9 | +var covid19Endp types.Covid19Endpoints |
| 10 | +var Covid19Cmd = &cobra.Command{ |
| 11 | + Use: "covid19", |
| 12 | + Short: "Query covid19api.com website APIs.", |
| 13 | + Long: `Query covid19api.com website APIs. Detail see https://covid19api.com`, |
| 14 | + Run: func(cmd *cobra.Command, args []string) { |
| 15 | + Covid19CmdRunOptions(cmd, args) |
| 16 | + }, |
| 17 | +} |
| 18 | + |
| 19 | +func Covid19CmdRunOptions(cmd *cobra.Command, args []string) { |
| 20 | + if fetch.Covid19(&covid19Endp, &bapiClis, func() { initCmd(cmd, args) }, nil) { |
| 21 | + bapiClis.HelpFlags = false |
| 22 | + } |
| 23 | + if bapiClis.HelpFlags { |
| 24 | + cmd.Help() |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +func init() { |
| 29 | + setGlobalFlag(Covid19Cmd, &bapiClis) |
| 30 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.AllRoute, "all", "", false, `Get all Data.`) |
| 31 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountriesRoute, "cts", "", false, `Get list of countries.`) |
| 32 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryDayOneRoute, "ct-d-one", "", false, `Get list of cases per country per province by case type from the first recorded case.`) |
| 33 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryDayOneTotalRoute, "ct-d-one-total", "", false, `Get list of cases per country by case type from the first recorded case.`) |
| 34 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryRoute, "ct", "", false, `Get list of cases per country per province by case type.`) |
| 35 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusDayOneLiveRoute, "ct-st-d-one-live", "", false, `Get list of cases per country per province by case type from the first recorded case, updated with latest live count.`) |
| 36 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusDayOneRoute, "ct-st-d-one", "", false, `Get list of cases per country per province by case type from the first recorded case".`) |
| 37 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusDayOneTotalRoute, "ct-st-d-one-total", "", false, `Get list of cases per country by case type from the first recorded case.`) |
| 38 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusLiveRoute, "ct-st-live", "", false, `Daily list of cases per country per province by case type, updated with latest live count.`) |
| 39 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusRoute, "ct-st", "", false, `Get list of cases per country per province by case type.`) |
| 40 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryStatusTotalRoute, "ct-st-total", "", false, `Get list of cases per country by case type.`) |
| 41 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.CountryTotalRoute, "ct-total", "", false, `Get list of cases per country by case type.`) |
| 42 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.ExportRoute, "export", "", false, `Get all data as a zip file.`) |
| 43 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.LiveCountryRoute, "live-ct", "", false, `Get live list of cases per country per province by case type.`) |
| 44 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.LiveCountryStatusAfterDateRoute, "live-ct-st-date", "", false, `Get a time series of cases per country per province by case type after a date.`) |
| 45 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.LiveCountryStatusRoute, "live-ct-st", "", false, `Get a time series of cases per country per province by case type.`) |
| 46 | + Covid19Cmd.Flags().BoolVarP(&covid19Endp.SummaryRoute, "summary", "", false, `Summary of new and total cases per country.`) |
| 47 | + Covid19Cmd.Flags().StringVarP(&covid19Endp.WebhookRoute, "webhook", "", "", `Add a webhook to be notified when new data becomes available.`) |
| 48 | + |
| 49 | + Covid19Cmd.Flags().StringVarP(&covid19Endp.Country, "name", "", "", `Country name.`) |
| 50 | + Covid19Cmd.Flags().StringVarP(&covid19Endp.Status, "status", "", "", `Patient status [confirmed, recovered, deaths].`) |
| 51 | + Covid19Cmd.Flags().StringVarP(&covid19Endp.Date, "date", "", "", `After a given date.`) |
| 52 | + |
| 53 | + Covid19Cmd.Example = ` # returns all data in the system. Warning: this request returns 8MB+ and takes 5+ seconds |
| 54 | + bget api covid19 --all |
| 55 | + # returns all countries and associated provinces |
| 56 | + bget api covid19 --cts |
| 57 | + # returns all cases by case type for a country from the first recorded case. |
| 58 | + bget api covid19 --ct --name China |
| 59 | + # returns all cases by case type for a country from the first recorded case. |
| 60 | + bget api covid19 --ct-d-one --name China |
| 61 | + # returns all cases by case type for a country. |
| 62 | + bget api covid19 --ct-d-one-total --name China |
| 63 | + # returns all cases by case type for a country from the first recorded case with the latest record being the live count. |
| 64 | + bget api covid19 --ct-st-d-one --name China --status confirmed |
| 65 | + # returns all cases by case type for a country from the first recorded case. |
| 66 | + bget api covid19 --ct-st-d-one-live --name China --status confirmed |
| 67 | + # returns all cases by case type for a country from the first recorded case |
| 68 | + bget api covid19 --ct-st-d-one-total --name China --status confirmed |
| 69 | + # returns all cases by case type for a country with the latest record being the live count. |
| 70 | + bget api covid19 --ct-st-live --name China --status confirmed |
| 71 | + # returns all cases by case type for a country. |
| 72 | + bget api covid19 --ct-st --name China --status confirmed |
| 73 | + # returns all cases by case type for a country. |
| 74 | + bget api covid19 --ct-st-total --name China --status confirmed |
| 75 | + # returns all cases of a country. |
| 76 | + bget api covid19 --ct-total --name China |
| 77 | + # returns all live cases by case type for a country. |
| 78 | + bget api covid19 --live-ct --name China |
| 79 | + # returns all live cases by case type for a country after a given date. |
| 80 | + bget api covid19 --live-ct-st-date --name China --status confirmed --date 2020-04-20T06:20:47Z |
| 81 | + # returns all live cases by case type for a country. |
| 82 | + bget api covid19 --live-ct-st --name China --status confirmed |
| 83 | + # a summary of new and total cases per country |
| 84 | + bget api covid19 --summary |
| 85 | + bget api covid19 --export |
| 86 | + bget api covid19 --webhook https://your_webhook.com` |
| 87 | +} |
0 commit comments