Updating cryptocurrency to use rate.sx
This commit is contained in:
parent
52d1d022a6
commit
ac76f298db
17
README.md
17
README.md
|
@ -82,7 +82,7 @@ crypt -d [encrypted file] [output file] # decrypts files
|
|||
<details>
|
||||
<summary>Cryptocurrency</summary>
|
||||
|
||||
Converts Cryptocurrency based on realtime exchange rates
|
||||
Converts Cryptocurrency based on realtime exchange rates of the top 10 cryptos
|
||||
|
||||
<div align="center">
|
||||
|
||||
|
@ -90,21 +90,13 @@ Converts Cryptocurrency based on realtime exchange rates
|
|||
|
||||
</div>
|
||||
|
||||
Run `cryptocurrency` and you'll be guided through providing three arguments.
|
||||
1. Base currency, i.e. `BTC`
|
||||
2. Target currency, i.e. `USD`
|
||||
3. Amount, i.e. `12.35`
|
||||
|
||||
If you want to bypass the guided input you can pass in 3 arguments and it will run from there, i.e.
|
||||
```bash
|
||||
cryptocurrency [baseCurrency] [exchangeToCurrency] [amountBeingExchanged]
|
||||
```
|
||||
A valid use case would be:
|
||||
```bash
|
||||
cryptocurrency BTC USD 12.35
|
||||
cryptocurrency -f eur
|
||||
```
|
||||
|
||||
Written by: [Jonas-Taha El Sesiy](https://github.com/elsesiy)
|
||||
Originally written by: [Jonas-Taha El Sesiy](https://github.com/elsesiy)
|
||||
Heavy modifications by: [Alex Epstein](https://github.com/alexanderepstein)
|
||||
</details>
|
||||
|
||||
|
||||
|
@ -371,6 +363,7 @@ Written by: [Linyos Torovoltos](http://github.com/linyostorovovoltos)
|
|||
* To transfer files: [transfer](https://transfer.sh)
|
||||
* To grab lyrics from a song: [lyrics.ovh](http://docs.lyricsovh.apiary.io)
|
||||
* To generate memes: [MemeGen](https://memegen.link)
|
||||
* To get a chart of the top 10 cryptocurrencies [rate.sx](http://rate.sx)
|
||||
|
||||
</details>
|
||||
|
||||
|
|
|
@ -155,10 +155,16 @@ crypt \-d myEncryptedFile\.jpg thisIsNowDecrypted\.txt (change filetype back so
|
|||
.IP "" 0
|
||||
.
|
||||
.SS "CryptoCurrency"
|
||||
Description: A realtime cryptocurrency converter\. With no flags it will guide you through the cryptocurrency exchange
|
||||
Description: A realtime cryptocurrency converter\. With no flags it will pull down the latest stats of the top 10 cryptos
|
||||
.
|
||||
.P
|
||||
Usage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [base] [exchangeTo] [amount]
|
||||
Usage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [flag] [arg]
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
\-o Utilize the old functionality of the tool
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
\-f Fiat currency for conversions
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
\-u Update Bash\-Snippet Tools
|
||||
|
@ -172,19 +178,7 @@ Usage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [base] [exchang
|
|||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
Supported Base Currencies:
|
||||
.
|
||||
.P
|
||||
| BTC | ETH | XRP | LTC | | XEM | ETC | DASH | MIOTA | | XMR | STRAT |
|
||||
.
|
||||
.P
|
||||
Supported Target Currencies:
|
||||
.
|
||||
.P
|
||||
| AUD | BRL | CAD | CHF | | CNY | EUR | GBP | HKD | | IDR | INR | JPY | KRW | | MXN | RUB | USD |
|
||||
.
|
||||
.P
|
||||
Examples: cryptocurrency BTC USD 12\.35 cryptocurrency
|
||||
Examples: cryptocurrency \-o cryptocurrency \-f eur
|
||||
.
|
||||
.SS "Currency"
|
||||
Description: A realtime currency converter\. With no flags it will guide you through the currency exchange
|
||||
|
|
|
@ -97,9 +97,13 @@ Examples:
|
|||
|
||||
### CryptoCurrency
|
||||
Description: A realtime cryptocurrency converter.
|
||||
With no flags it will guide you through the cryptocurrency exchange
|
||||
With no flags it will pull down the latest stats of the top 10 cryptos
|
||||
|
||||
Usage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [base] [exchangeTo] [amount]
|
||||
Usage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [flag] [arg]
|
||||
|
||||
* -o Utilize the old functionality of the tool
|
||||
|
||||
* -f Fiat currency for conversions
|
||||
|
||||
* -u Update Bash-Snippet Tools
|
||||
|
||||
|
@ -107,24 +111,11 @@ Usage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [base] [exchang
|
|||
|
||||
* -v Get the tool version
|
||||
|
||||
Supported Base Currencies:
|
||||
___________________________
|
||||
| BTC | ETH | XRP | LTC |
|
||||
| XEM | ETC | DASH | MIOTA |
|
||||
| XMR | STRAT |
|
||||
___________________________
|
||||
|
||||
Supported Target Currencies:
|
||||
________________________
|
||||
| AUD | BRL | CAD | CHF |
|
||||
| CNY | EUR | GBP | HKD |
|
||||
| IDR | INR | JPY | KRW |
|
||||
| MXN | RUB | USD |
|
||||
_______________________
|
||||
|
||||
Examples:
|
||||
cryptocurrency BTC USD 12.35
|
||||
cryptocurrency
|
||||
cryptocurrency -o
|
||||
cryptocurrency -f eur
|
||||
|
||||
### Currency
|
||||
Description: A realtime currency converter.
|
||||
|
@ -216,7 +207,7 @@ Examples:
|
|||
* lyrics -a logic -s run it
|
||||
|
||||
* lyrics -a logic -s run it -f ~/runItLyrics.txt
|
||||
|
||||
|
||||
### Meme
|
||||
Description: A lightning fast meme generator
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
# Author: Jonas-Taha El Sesiy https://github.com/elsesiy
|
||||
# Original Author: Jonas-Taha El Sesiy https://github.com/elsesiy
|
||||
# Modifications: Alexander Epstein
|
||||
|
||||
base=""
|
||||
exchangeTo=""
|
||||
unset base
|
||||
unset exchangeTo
|
||||
old="false"
|
||||
currentVersion="1.20.0"
|
||||
configuredClient=""
|
||||
unset configuredClient
|
||||
|
||||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient()
|
||||
|
@ -238,38 +240,21 @@ usage()
|
|||
CryptoCurrency
|
||||
|
||||
Description: A realtime cryptocurrency converter.
|
||||
With no flags it will guide you through the cryptocurrency exchange
|
||||
With no flags it will pull down the latest stats of the top 10 cryptos
|
||||
|
||||
Usage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [base] [exchangeTo] [amount]
|
||||
Usage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [flag] [arg]
|
||||
-u Update Bash-Snippet Tools
|
||||
-h Show the help
|
||||
-v Get the tool version
|
||||
|
||||
Supported Base Currencies:
|
||||
___________________________
|
||||
| BTC | ETH | XRP | LTC |
|
||||
| XEM | ETC | DASH | MIOTA |
|
||||
| XMR | STRAT | BCH |
|
||||
___________________________
|
||||
|
||||
Supported Target Currencies:
|
||||
________________________
|
||||
| AUD | BRL | CAD | CHF |
|
||||
| CNY | EUR | GBP | HKD |
|
||||
| IDR | INR | JPY | KRW |
|
||||
| MXN | RUB | USD |
|
||||
_______________________
|
||||
|
||||
Examples:
|
||||
cryptocurrency BTC USD 12.35
|
||||
cryptocurrency
|
||||
-o Utilize the old functionality of the tool
|
||||
-f Fiat currency for conversions
|
||||
EOF
|
||||
}
|
||||
|
||||
getConfiguredClient || exit 1
|
||||
|
||||
|
||||
while getopts "uvh" opt; do
|
||||
|
||||
while getopts "f:uvh" opt; do
|
||||
case "$opt" in
|
||||
\?) echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
|
@ -277,6 +262,12 @@ while getopts "uvh" opt; do
|
|||
h) usage
|
||||
exit 0
|
||||
;;
|
||||
f)
|
||||
fiat=$OPTARG
|
||||
;;
|
||||
o)
|
||||
old="true"
|
||||
;;
|
||||
v) echo "Version $currentVersion"
|
||||
exit 0
|
||||
;;
|
||||
|
@ -290,37 +281,32 @@ while getopts "uvh" opt; do
|
|||
esac
|
||||
done
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here
|
||||
getBase # get base currency
|
||||
getExchangeTo # get exchange to currency
|
||||
getAmount # get the amount to be converted
|
||||
transformBase
|
||||
convertCurrency # grab the exhange rate and perform the conversion
|
||||
exit 0
|
||||
elif [[ $# == "1" ]]; then
|
||||
if [[ $1 == "update" ]]; then
|
||||
checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here
|
||||
update
|
||||
elif [[ $1 == "help" ]]; then
|
||||
usage
|
||||
else
|
||||
echo "Not a valid argument"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
elif [[ $# == "2" ]]; then
|
||||
echo "Not a valid argument"
|
||||
usage
|
||||
exit 1
|
||||
elif [[ $# == "3" ]]; then
|
||||
checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here
|
||||
checkBase $1
|
||||
checkExchangeTo $2
|
||||
checkAmount $3
|
||||
transformBase
|
||||
convertCurrency
|
||||
exit 0
|
||||
else
|
||||
echo "Error: too many arguments"
|
||||
if $old;then
|
||||
getConfiguredClient || exit 1
|
||||
getBase # get base currency
|
||||
getExchangeTo # get exchange to currency
|
||||
getAmount # get the amount to be converted
|
||||
transformBase
|
||||
convertCurrency # grab the exhange rate and perform the conversion
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [[ $1 == "update" ]]; then
|
||||
getConfiguredClient || exit 1
|
||||
checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here
|
||||
update
|
||||
exit 0
|
||||
elif [[ $1 == "help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
getConfiguredClient || exit 1
|
||||
checkInternet || exit 1
|
||||
if [[ $fiat =~ [a-zA-Z] ]]; then
|
||||
httpGet $fiat.rate.sx
|
||||
else
|
||||
httpGet rate.sx
|
||||
fi
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 99 KiB |
|
@ -18,13 +18,6 @@ fi
|
|||
[ "${lines[0]}" = "CryptoCurrency" ]
|
||||
}
|
||||
|
||||
@test "Testing cryptocurrency exchange (12.35 BTC TO USD)" {
|
||||
run cryptocurrency BTC USD 12.35
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${lines[0]}" = "=========================" ]
|
||||
[ "${lines[3]}" = "| BTC: 12.35" ]
|
||||
}
|
||||
|
||||
@test "Get the tools version with -v" {
|
||||
run cryptocurrency -v
|
||||
[ "$status" -eq 0 ]
|
||||
|
|
Loading…
Reference in New Issue