From 2c568fc74a819849620f8fbe59e181ce12382b44 Mon Sep 17 00:00:00 2001 From: Asa Venton Date: Sat, 31 Oct 2020 05:29:26 +0000 Subject: General tidy up of code, comments, usage, remove testing lines. --- flightquery.sh | 14 +++++++------- 1 file 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 ]] -- cgit v1.2.3