ebird-cli-0.3.0.1: A command-line utility for interacting with the eBird API.
Copyright(c) 2023 Finley McIlwaine
LicenseMIT (see LICENSE)
MaintainerFinley McIlwaine <finleymcilwaine@gmail.com>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.EBird.CLI

Description

Functions used to implement a command-line utility for interacting with the eBird API.

Synopsis

Documentation

eBirdCli :: IO () Source #

Entry point for the ebird CLI. Parses the command arguments, selects an API key, and executes the command.

The API key may be provided as a command-line option. If the key option is not provided, it is read from the file ~/.ebird/key.txt. If that file is unavailable for reading, and no key option is provided, the application exits (if the command requires a key).

readEBirdAPIKey :: IO (Maybe Text) Source #

Read an eBird API key from ~/.ebird/key.txt. If the file exists and is available for reading, the result is Just the contents of the file, stripped of leading/trailing whitespace. Otherwise, the result is Nothing.

runEBirdCommand Source #

Arguments

:: IO Text

Get an API key (this may fail if not found or provided)

-> EBirdCommand

Command to execute

-> IO () 

Run an EBirdCommand with a given API key.

printResJSON :: ToJSON a => a -> IO () Source #

Simply prints a value as prettified JSON

eBirdFail :: String -> IO a Source #

Print a string to stderr, prepended with a context string, and exit with failure status.

data EBirdCommand Source #

Each EBirdCommand corresponds to an endpoint of the eBird API

Instances

Instances details
Show EBirdCommand Source # 
Instance details

Defined in Data.EBird.CLI

Eq EBirdCommand Source # 
Instance details

Defined in Data.EBird.CLI

data RecentNearbyObservationsOptions Source #

Options for the recent-nearby-observations command.

data RecentNearbySpeciesObservationsOptions Source #

Options for the recent-nearby-species-observations command.

data RecentNearestSpeciesObservationsOptions Source #

Options for the recent-nearest-species-observations command.

data RecentNearbyNotableObservationsOptions Source #

Options for the recent-nearby-notable-observations command.

data Top100Options Source #

Options for the top-100 command.

Constructors

Top100Options 

Fields

data TaxonomyOptions Source #

Options for the nearby-hotspots command.

Constructors

TaxonomyOptions 

Fields

eBirdCommand :: Parser (Maybe Text, EBirdCommand) Source #

Parse a command provided to the ebird CLI.

recentObservationsOptions :: Parser RecentObservationsOptions Source #

Parse the options for the recent-observations command.

recentNotableObservationsOptions :: Parser RecentNotableObservationsOptions Source #

Parse the options for a recent-notable-observations command.

recentSpeciesObservationsOptions :: Parser RecentSpeciesObservationsOptions Source #

Parse the options for a recent-species-observations command.

recentNearbyObservationsOptions :: Parser RecentNearbyObservationsOptions Source #

Parse the options for a recent-nearby-observations command.

recentNearbySpeciesObservationsOptions :: Parser RecentNearbySpeciesObservationsOptions Source #

Parse the options for a recent-nearby-species-observations command.

recentNearestSpeciesObservationsOptions :: Parser RecentNearestSpeciesObservationsOptions Source #

Parse the options for a recent-nearest-species-observations command.

recentNearbyNotableObservationsOptions :: Parser RecentNearbyNotableObservationsOptions Source #

Parse the options for a recent-nearest-species-observations command.

historicalObservationsOptions :: Parser HistoricalObservationsOptions Source #

Parse the options for a historical-observations command.

observationOnlyHotspotsOpt :: Parser Bool Source #

Parse a Bool, intended to be used as an option determining whether to include observations from hotspots in the response.

observationIncludeProvisionalOpt :: Parser Bool Source #

Parse a Bool, intended to be used as an option determining whether to include unreviewed observations in the response.

observationMaxResultsOpt :: Parser Integer Source #

Parse a Integer option indicating the number of results to include in the response.

regionCodeOpt Source #

Arguments

:: String

What are we fetching? (e.g. "observations")

-> Parser RegionCode 

Parse a RegionCode as a generic command option, intended for use with the observation commands.

taxonomyCategoriesOpt Source #

Arguments

:: String

String to include after "one or more taxonomy categories to include ..."

-> Parser TaxonomyCategories 

Configurable TaxonomyCategories parser

observationSortByOpt :: Parser SortObservationsBy Source #

Parse a SortObservationsBy as an option determining how returned observations will be sorted.

observationDetailLevelOpt :: Parser DetailLevel Source #

Parse a DetailLevel as an option determining the detail level of observations in the result.

extraRegionsOpt :: Parser RegionCode Source #

Parse a RegionCode as extra regions to fetch observations from

recentChecklistsOptions :: Parser RecentChecklistsOptions Source #

Parse the options for a recent-checklists command.

top100Options :: Parser Top100Options Source #

Parse the options for a top-100 command.

checklistFeedOptions :: Parser ChecklistFeedOptions Source #

Parse the options for a top-100 command.

regionalStatisticsOptions :: Parser RegionalStatisticsOptions Source #

Parse the options for a regional-statistics command.

speciesListOptions :: Parser SpeciesListOptions Source #

Parse the options for a regional-statistics command.

viewChecklistOptions :: Parser ViewChecklistOptions Source #

Parse the options for a regional-statistics command.

checklistRegionCodeOpt :: Parser RegionCode Source #

Parse a RegionCode as a generic command option, intended for use with the checklists commands.

checklistMaxResultsOpt :: Parser Integer Source #

Parse a Integer as a generic command option, intended for use with the checklists commands for determining max results to include.

regionHotspotsOptions :: Parser RegionHotspotsOptions Source #

Parse the options for a region-hotspots command.

nearbyHotspotsOptions :: Parser NearbyHotspotsOptions Source #

Parse the options for a nearby-hotspots command.

hotspotInfoOptions :: Parser HotspotInfoOptions Source #

Parse the options for a hotspot-info command.

taxonomyOptions :: Parser TaxonomyOptions Source #

Parse the options for a nearby-hotspots command.

taxonomicFormsOptions :: Parser TaxonomicFormsOptions Source #

Parse the options for a taxonomic-forms command.

taxaLocaleCodesOptions :: Parser TaxaLocaleCodesOptions Source #

Parse the options for a taxa-locale-codes command.

taxonomicGroupsOptions :: Parser TaxonomicGroupsOptions Source #

Parse the options for a taxa-locale-codes command.

regionInfoOptions :: Parser RegionInfoOptions Source #

Parse the options for the region-info command.

subregionListOptions :: Parser SubregionListOptions Source #

Parse the options for the subregions command.

adjacentRegionsOptions :: Parser AdjacentRegionsOptions Source #

Parse the options for the subregions command.

sppLocaleOpt :: String -> Parser SPPLocale Source #

Parse a SPPLocale as a generic command option.

region :: Parser Region Source #

Parse a Region as a generic command option.

regionCode :: Parser RegionCode Source #

Parse a RegionCode as a generic command option.

regionNameFormat :: Parser RegionNameFormat Source #

Parse a RegionNameFormat as a generic command option.

regionType :: Parser RegionType Source #

Parse a RegionType as a generic command option.

speciesCodeOpt :: String -> Parser SpeciesCode Source #

Configurable SpeciesCode option

searchRadiusOpt Source #

Arguments

:: String

What are we searching for (e.g. "observations")

-> Integer

Maximum allowed value by the API

-> Maybe Integer

Default value of the API (Nothing for "no limit")

-> Parser Integer 

Configurable "search radius" option

backOpt Source #

Arguments

:: String

What are we fetching (e.g. "hotspots")

-> String

Verb we are filtering on (e.g. "submitted", or "visited")

-> Maybe Integer

Default value (Nothing for "no limit")

-> Parser Integer 

Configurable "back" option

latLngOpt Source #

Arguments

:: String

"latitude" or "longitude"

-> String

What are we looking for

-> Parser Double 

Configurable lat/lng option

attoReadM :: Parser a -> ReadM a Source #

Convert an attoparsec parser into an optparse-applicative parser.