aboutsummaryrefslogtreecommitdiff
path: root/templates/.bin/metar
diff options
context:
space:
mode:
authorBen Burwell <ben@benburwell.com>2019-08-13 14:40:54 -0400
committerBen Burwell <ben@benburwell.com>2019-08-13 14:40:54 -0400
commitc09d91fe95fca4367f47c06fc808cd02a1a8e6a5 (patch)
tree6c5c8dee0c219ab701dc1ff4c39e905dbac08e70 /templates/.bin/metar
add bins
Diffstat (limited to 'templates/.bin/metar')
-rwxr-xr-xtemplates/.bin/metar29
1 files changed, 29 insertions, 0 deletions
diff --git a/templates/.bin/metar b/templates/.bin/metar
new file mode 100755
index 0000000..a9d7429
--- /dev/null
+++ b/templates/.bin/metar
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+say=0
+jq="/usr/bin/jq"
+if [[ ! -x "$jq" && -x "/usr/local/bin/jq" ]]; then
+ jq="/usr/local/bin/jq"
+fi
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -s|--say)
+ say=1
+ ;;
+ -*)
+ echo "Unknown option flag: $1"
+ exit 1
+ ;;
+ *)
+ station=$(echo -n "$1" | tr "a-z" "A-Z")
+ ;;
+ esac
+ shift
+done
+json=$(curl -s "https://avwx.rest/api/metar/${station:-KBOS}?options=speech")
+if [ $say -gt 0 ]; then
+ echo "$json" | "$jq" --raw-output '.Speech' 2>&1 | say
+else
+ echo "$json" | "$jq" --raw-output '.["Raw-Report"]' 2>&1
+fi