aboutsummaryrefslogtreecommitdiff
path: root/scripts/rate-sx.sh
blob: baec2704af37d5bc8caf0f7d407990c97be8699d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;