diff options
author | Asa Venton <asav1410@gmail.com> | 2020-10-31 04:30:55 +0000 |
---|---|---|
committer | Asa Venton <asav1410@gmail.com> | 2020-10-31 04:30:55 +0000 |
commit | 487b879043838a01a955f872d6adfa64766ebb59 (patch) | |
tree | 32c7498e0a1820d0b1d6b7b33ef2d713ce067f5d /flightquery.sh | |
parent | f1902d6653ced4e841c13113a8a558ad248e121d (diff) |
Add very basic support for departures and arrivals from a given airport. Not currently compatible with IRC bot. Update help.
Diffstat (limited to 'flightquery.sh')
-rwxr-xr-x | flightquery.sh | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/flightquery.sh b/flightquery.sh index 16910e6..cb8edb3 100755 --- a/flightquery.sh +++ b/flightquery.sh @@ -33,10 +33,30 @@ _getdata() { _arrivals() { _getdata + # 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 + for json in $(echo "${result}" | jq -r '.data[] | @base64') + do + origin=$(_jq '.departure.airport') + takeoffSched=$(_jq '.departure.scheduled') + landingSched=$(_jq '.arrival.scheduled') + airline=$(_jq '.airline.name') + flightNumber=$(_jq '.flight.number') + echo "$airline $flightNumber Origin: $origin Takeoff: $takeoffSched Landed: $landingSched" + done } _departures() { _getdata + # 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 + for json in $(echo "${result}" | jq -r '.data[] | @base64') + do + destination=$(_jq '.arrival.airport') + takeoffSched=$(_jq '.departure.scheduled') + landingSched=$(_jq '.arrival.scheduled') + airline=$(_jq '.airline.name') + flightNumber=$(_jq '.flight.number') + echo "$airline $flightNumber destination: $destination Takeoff: $takeoffSched Landed: $landingSched" + done } _flight() { @@ -85,7 +105,7 @@ _flight() { } _help() { - echo "Usage: !flight [option] [flight]. Options: -h help, -d departures, -a arrivals, -s source." + 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." } if [[ ${input} == "-h" ]] || [[ ${input} == "--help" ]] || [[ -z $input ]] |