aboutsummaryrefslogtreecommitdiff
path: root/scripts/rate-sx.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/rate-sx.sh')
-rwxr-xr-xscripts/rate-sx.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/rate-sx.sh b/scripts/rate-sx.sh
new file mode 100755
index 0000000..baec270
--- /dev/null
+++ b/scripts/rate-sx.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+
+rate_sx() {
+ [[ ! -z "$2" ]] \
+ && curl $2.rate.sx/$1 \
+ || curl rate.sx/$1;
+}
+
+get_1() { cut -d' ' -f1; }
+get_2() { cut -d' ' -f2; }
+
+help() {
+ echo "
+::: Rate.sx repl :::
+ btc: get graph for btc in usd
+ btc inr: get graph for btc in inr
+ 1btc inr: print the value of 1btc in inr
+ q: quit
+";
+}
+
+help;
+
+while true; do
+ while IFS="" read -r -e -d $'\n' -p 'rate.sx $ ' command; do
+ case "$(echo $command | get_1)" in
+ q) exit 0 ;;
+ *) rate_sx $command ;;
+ esac;
+ done;
+done;
+