summaryrefslogtreecommitdiff
path: root/home/xyz/.local
diff options
context:
space:
mode:
Diffstat (limited to 'home/xyz/.local')
-rwxr-xr-xhome/xyz/.local/bin/rate10
1 files changed, 9 insertions, 1 deletions
diff --git a/home/xyz/.local/bin/rate b/home/xyz/.local/bin/rate
index a20d70f9..1625df62 100755
--- a/home/xyz/.local/bin/rate
+++ b/home/xyz/.local/bin/rate
@@ -1,3 +1,11 @@
#!/bin/sh
-curl -sS "rate.sx/${1:-1xmr}"
+while getopts f:t: opt; do
+ case $opt in
+ f) from="$OPTARG";;
+ t) to="$(echo "$OPTARG" | tr '[:lower:]' '[:upper:]')";;
+ \?) exit 1;;
+ esac
+done
+# https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-exchange-rates
+curl -s "https://api.coinbase.com/v2/exchange-rates?currency=${from:-xmr}" | jq -r ".data.rates.${to:-USD}"