summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xflightquery.sh14
1 files changed, 7 insertions, 7 deletions
diff --git a/flightquery.sh b/flightquery.sh
index 2382fa6..65b9e03 100755
--- a/flightquery.sh
+++ b/flightquery.sh
@@ -24,17 +24,17 @@ _jq() {
}
_getdata() {
- # Take everything after final space as the requested input (be it an airport IATA or flight ICAO), assuming everything before the last space is a flag
+ # Take everything after final space as the requested input (be it an IATA airport code or IATA flight number), assuming everything before the last space is a flag
code=$(echo $input | sed 's/.* //')
URL="$baseURL&$queryType=$code"
_curl
- #echo $result | python -m json.tool
}
_arrivals() {
_getdata
+ # Extract .data and sort by scheduled landing
result=$(echo $result | jq '.data | sort_by(.arrival.scheduled)')
- # TODO: Sort by something (arrival time?), limit to a certin number of flights (X before current time and Y after?) and format on single line of output
+ # TODO: Limit to a certin number of flights (X before current time and Y after?) and format on single line of output
for json in $(echo "${result}" | jq -r '.[] | @base64')
do
origin=$(_jq '.departure.airport')
@@ -48,8 +48,9 @@ _arrivals() {
_departures() {
_getdata
+ # Extract .data and sort by scheduled takeoff
result=$(echo $result | jq '.data | sort_by(.departure.scheduled)')
- # TODO: Sort by something (departure time?), limit to a certin number of flights (X before current time and Y after?) and format on single line of output
+ # TODO: Limit to a certin number of flights (X before current time and Y after?) and format on single line of output
for json in $(echo "${result}" | jq -r '.[] | @base64')
do
destination=$(_jq '.arrival.airport')
@@ -73,7 +74,7 @@ _flight() {
landingEst=$(echo $result | jq -r '.data[0].arrival.estimated')
landingDelay=$(echo $result | jq -r '.data[0].arrival.delay')
- # Build output strings giving estimated times and delays where available.
+ # Build output string giving estimated times and delays where available.
output="$airline - Origin: $origin "
if [[ "$takeoffEst" != "null" ]]
then
@@ -102,11 +103,10 @@ _flight() {
fi
echo $output
-
}
_help() {
- echo "Usage: !flight [option] [flight/airport]. Options: -h help, -d departures [airport], -a arrivals [airport], -s source. If no option is set then you must provide an IATA flight number e.g. BA2775."
+ echo "Usage: !flight [option] [flight/airport]. Options: -h help, -d departures [IATA airport code], -a arrivals [IATA airport code], -s source. If no option is set then you must provide an IATA flight number e.g. BA2775."
}
if [[ ${input} == "-h" ]] || [[ ${input} == "--help" ]] || [[ -z $input ]]