diff options
author | Asa Venton <asav1410@gmail.com> | 2020-10-31 05:29:26 +0000 |
---|---|---|
committer | Asa Venton <asav1410@gmail.com> | 2020-10-31 05:29:26 +0000 |
commit | 2c568fc74a819849620f8fbe59e181ce12382b44 (patch) | |
tree | 7613605f8359f50e3a4305a1b4704fbdf5a80986 | |
parent | 7ed1d3da600703294d9b06cf2258c2813a89080e (diff) |
General tidy up of code, comments, usage, remove testing lines.
-rwxr-xr-x | flightquery.sh | 14 |
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 ]] |