commit 73b4f7b0f55919201dfd51e3db0a85fe7cbdcf46
parent 94e84616f0b02a03a5bfed5fb25bc5f00f2a5c3a
Author: Alex Balgavy <alex@balgavy.eu>
Date: Thu, 19 May 2022 20:05:46 +0200
xe: rewrite in go, move to separate repo
Now installable from my homebrew tap or directly https://github.com/thezeroalpha/xe
Diffstat:
D | scripts/xe | | | 36 | ------------------------------------ |
1 file changed, 0 insertions(+), 36 deletions(-)
diff --git a/scripts/xe b/scripts/xe
@@ -1,36 +0,0 @@
-#!/bin/sh
-# A CLI utility for exchange rates via https://www.xe.com
-checkdeps() {
- for com in "$@"; do
- command -v "$com" >/dev/null 2>&1 \
- || { printf '%s required but not found.\n' "$com" >&2 && exit 1; }
- done
-}
-checkdeps curl pup tr
-
-die() { printf '%s\n' "$1" >&2 && exit 1; }
-
-# if args == amount from to
-if [ $# -eq 3 ]; then
- amount="$1"
- from="$(printf '%s' "$2" | tr '[:lower:]' '[:upper:]')"
- to="$(printf '%s' "$3" | tr '[:lower:]' '[:upper:]')"
-# if args == from to, and amount on stdin
-elif ! [ -t 0 ] && [ $# -eq 2 ]; then
- read -r amount
- from="$(printf '%s' "$1" | tr '[:lower:]' '[:upper:]')"
- to="$(printf '%s' "$2" | tr '[:lower:]' '[:upper:]')"
-# else usage is incorrect
-else
- die 'Usage: xe AMOUNT FROM_CURRENCY TO_CURRENCY'
-fi
-
-
-curl -sL "https://www.xe.com/currencyconverter/convert/?Amount=$amount&From=$from&To=$to" \
- -H 'authority: www.xe.com' \
- -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
- -H 'accept-language: en-US,en;q=0.9,uk-UA;q=0.8,uk;q=0.7,ru-RU;q=0.6,ru;q=0.5' \
- -H 'cache-control: no-cache' \
- -H 'pragma: no-cache' \
- -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36' \
- | pup 'p[class*=result__BigRate] text{}' | tr -d '\n'