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>
|
<details>
|
||||||
<summary>Cryptocurrency</summary>
|
<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">
|
<div align="center">
|
||||||
|
|
||||||
|
@ -90,21 +90,13 @@ Converts Cryptocurrency based on realtime exchange rates
|
||||||
|
|
||||||
</div>
|
</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:
|
A valid use case would be:
|
||||||
```bash
|
```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>
|
</details>
|
||||||
|
|
||||||
|
|
||||||
|
@ -371,6 +363,7 @@ Written by: [Linyos Torovoltos](http://github.com/linyostorovovoltos)
|
||||||
* To transfer files: [transfer](https://transfer.sh)
|
* To transfer files: [transfer](https://transfer.sh)
|
||||||
* To grab lyrics from a song: [lyrics.ovh](http://docs.lyricsovh.apiary.io)
|
* To grab lyrics from a song: [lyrics.ovh](http://docs.lyricsovh.apiary.io)
|
||||||
* To generate memes: [MemeGen](https://memegen.link)
|
* To generate memes: [MemeGen](https://memegen.link)
|
||||||
|
* To get a chart of the top 10 cryptocurrencies [rate.sx](http://rate.sx)
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
|
@ -155,10 +155,16 @@ crypt \-d myEncryptedFile\.jpg thisIsNowDecrypted\.txt (change filetype back so
|
||||||
.IP "" 0
|
.IP "" 0
|
||||||
.
|
.
|
||||||
.SS "CryptoCurrency"
|
.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
|
.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
|
.IP "\(bu" 4
|
||||||
\-u Update Bash\-Snippet Tools
|
\-u Update Bash\-Snippet Tools
|
||||||
|
@ -172,19 +178,7 @@ Usage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [base] [exchang
|
||||||
.IP "" 0
|
.IP "" 0
|
||||||
.
|
.
|
||||||
.P
|
.P
|
||||||
Supported Base Currencies:
|
Examples: cryptocurrency \-o cryptocurrency \-f eur
|
||||||
.
|
|
||||||
.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
|
|
||||||
.
|
.
|
||||||
.SS "Currency"
|
.SS "Currency"
|
||||||
Description: A realtime currency converter\. With no flags it will guide you through the currency exchange
|
Description: A realtime currency converter\. With no flags it will guide you through the currency exchange
|
||||||
|
|
|
@ -97,9 +97,13 @@ Examples:
|
||||||
|
|
||||||
### CryptoCurrency
|
### CryptoCurrency
|
||||||
Description: A realtime cryptocurrency converter.
|
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
|
* -u Update Bash-Snippet Tools
|
||||||
|
|
||||||
|
@ -107,24 +111,11 @@ Usage: cryptocurrency or cryptocurrency [flag] or cryptocurrency [base] [exchang
|
||||||
|
|
||||||
* -v Get the tool version
|
* -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:
|
Examples:
|
||||||
cryptocurrency BTC USD 12.35
|
cryptocurrency -o
|
||||||
cryptocurrency
|
cryptocurrency -f eur
|
||||||
|
|
||||||
### Currency
|
### Currency
|
||||||
Description: A realtime currency converter.
|
Description: A realtime currency converter.
|
||||||
|
@ -216,7 +207,7 @@ Examples:
|
||||||
* lyrics -a logic -s run it
|
* lyrics -a logic -s run it
|
||||||
|
|
||||||
* lyrics -a logic -s run it -f ~/runItLyrics.txt
|
* lyrics -a logic -s run it -f ~/runItLyrics.txt
|
||||||
|
|
||||||
### Meme
|
### Meme
|
||||||
Description: A lightning fast meme generator
|
Description: A lightning fast meme generator
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/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=""
|
unset base
|
||||||
exchangeTo=""
|
unset exchangeTo
|
||||||
|
old="false"
|
||||||
currentVersion="1.20.0"
|
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
|
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||||
getConfiguredClient()
|
getConfiguredClient()
|
||||||
|
@ -238,38 +240,21 @@ usage()
|
||||||
CryptoCurrency
|
CryptoCurrency
|
||||||
|
|
||||||
Description: A realtime cryptocurrency converter.
|
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
|
-u Update Bash-Snippet Tools
|
||||||
-h Show the help
|
-h Show the help
|
||||||
-v Get the tool version
|
-v Get the tool version
|
||||||
|
-o Utilize the old functionality of the tool
|
||||||
Supported Base Currencies:
|
-f Fiat currency for conversions
|
||||||
___________________________
|
|
||||||
| 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
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
getConfiguredClient || exit 1
|
|
||||||
|
|
||||||
|
|
||||||
while getopts "uvh" opt; do
|
|
||||||
|
while getopts "f:uvh" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
\?) echo "Invalid option: -$OPTARG" >&2
|
\?) echo "Invalid option: -$OPTARG" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -277,6 +262,12 @@ while getopts "uvh" opt; do
|
||||||
h) usage
|
h) usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
f)
|
||||||
|
fiat=$OPTARG
|
||||||
|
;;
|
||||||
|
o)
|
||||||
|
old="true"
|
||||||
|
;;
|
||||||
v) echo "Version $currentVersion"
|
v) echo "Version $currentVersion"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
@ -290,37 +281,32 @@ while getopts "uvh" opt; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $# == 0 ]]; then
|
if $old;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
|
getConfiguredClient || exit 1
|
||||||
getBase # get base currency
|
getBase # get base currency
|
||||||
getExchangeTo # get exchange to currency
|
getExchangeTo # get exchange to currency
|
||||||
getAmount # get the amount to be converted
|
getAmount # get the amount to be converted
|
||||||
transformBase
|
transformBase
|
||||||
convertCurrency # grab the exhange rate and perform the conversion
|
convertCurrency # grab the exhange rate and perform the conversion
|
||||||
exit 0
|
exit 0
|
||||||
elif [[ $# == "1" ]]; then
|
fi
|
||||||
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
|
if [[ $1 == "update" ]]; then
|
||||||
usage
|
getConfiguredClient || exit 1
|
||||||
else
|
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
|
||||||
echo "Not a valid argument"
|
update
|
||||||
usage
|
exit 0
|
||||||
exit 1
|
elif [[ $1 == "help" ]]; then
|
||||||
fi
|
usage
|
||||||
elif [[ $# == "2" ]]; then
|
exit 0
|
||||||
echo "Not a valid argument"
|
fi
|
||||||
usage
|
|
||||||
exit 1
|
getConfiguredClient || exit 1
|
||||||
elif [[ $# == "3" ]]; then
|
checkInternet || 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
|
if [[ $fiat =~ [a-zA-Z] ]]; then
|
||||||
checkBase $1
|
httpGet $fiat.rate.sx
|
||||||
checkExchangeTo $2
|
else
|
||||||
checkAmount $3
|
httpGet rate.sx
|
||||||
transformBase
|
|
||||||
convertCurrency
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "Error: too many arguments"
|
|
||||||
fi
|
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" ]
|
[ "${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" {
|
@test "Get the tools version with -v" {
|
||||||
run cryptocurrency -v
|
run cryptocurrency -v
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
|
|
Loading…
Reference in New Issue