mirror of
https://github.com/Llewellynvdm/CoinRate.git
synced 2025-04-10 22:41:50 +00:00
Echo error but do not stop
This commit is contained in:
parent
e5bc8cf187
commit
6cf42ef064
19
functions.sh
19
functions.sh
@ -111,6 +111,8 @@ function getActiveCurrencyTarget () {
|
|||||||
get_Price
|
get_Price
|
||||||
# get the price value
|
# get the price value
|
||||||
value="${CurrencyPair[${Currency}${Target}]}"
|
value="${CurrencyPair[${Currency}${Target}]}"
|
||||||
|
# check that we have a value
|
||||||
|
if [ "${value}" != "null" ]; then
|
||||||
# set send key
|
# set send key
|
||||||
setSendKey
|
setSendKey
|
||||||
# set target values and perform action if only TargetValue given
|
# set target values and perform action if only TargetValue given
|
||||||
@ -128,6 +130,7 @@ function getActiveCurrencyTarget () {
|
|||||||
then
|
then
|
||||||
getTarget "$TargetBelowValue" "$value" 'setActionBelow'
|
getTarget "$TargetBelowValue" "$value" 'setActionBelow'
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# get the target
|
# get the target
|
||||||
@ -211,7 +214,11 @@ function setMessage () {
|
|||||||
local current_value="$2"
|
local current_value="$2"
|
||||||
local target_value="$3"
|
local target_value="$3"
|
||||||
# build message
|
# build message
|
||||||
message="${Currency} is ${target_type} ${target_value} ${Target} at ${current_value} ${Target}" &&
|
if (( "$showAB" == 1 )); then
|
||||||
|
message="${Currency} is ${target_type} ${target_value} ${Target} at ${current_value} ${Target}"
|
||||||
|
else
|
||||||
|
message="${Currency} at ${current_value} ${Target}"
|
||||||
|
fi
|
||||||
# first send to comand line
|
# first send to comand line
|
||||||
echoTweak "${message} - ${Datetimenow} " &&
|
echoTweak "${message} - ${Datetimenow} " &&
|
||||||
# is it send time
|
# is it send time
|
||||||
@ -405,9 +412,14 @@ function get_Price () {
|
|||||||
# check if we have and error
|
# check if we have and error
|
||||||
local error=($( echo "$json" | jq -r '.error'))
|
local error=($( echo "$json" | jq -r '.error'))
|
||||||
if [ "${error}" != "null" ]; then
|
if [ "${error}" != "null" ]; then
|
||||||
echo "Currency Pair: $error"
|
if (( "$allowEcho" == 1 )); then
|
||||||
exit 1
|
echo "...!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!..."
|
||||||
|
echoTweak "${json}"
|
||||||
|
echo "...!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!..."
|
||||||
fi
|
fi
|
||||||
|
# no currency pair found
|
||||||
|
CurrencyPair["${Currency}${Target}"]='null'
|
||||||
|
else
|
||||||
# set the value
|
# set the value
|
||||||
if [ "${API_target}" == "cex" ]; then
|
if [ "${API_target}" == "cex" ]; then
|
||||||
local value=($( echo "$json" | jq -r '.lprice'))
|
local value=($( echo "$json" | jq -r '.lprice'))
|
||||||
@ -417,6 +429,7 @@ function get_Price () {
|
|||||||
# add value to global bucket
|
# add value to global bucket
|
||||||
CurrencyPair["${Currency}${Target}"]="$value"
|
CurrencyPair["${Currency}${Target}"]="$value"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# run some validation against the options given
|
# run some validation against the options given
|
||||||
|
@ -70,6 +70,7 @@ Getting Coin Value in Fiat Currency at set price
|
|||||||
example: 14000 or 14000,15000
|
example: 14000 or 14000,15000
|
||||||
-b Send Notice below target value once a day
|
-b Send Notice below target value once a day
|
||||||
-a Send Notice above target value once a day (default)
|
-a Send Notice above target value once a day (default)
|
||||||
|
-k hide the above and below from result string
|
||||||
|
|
||||||
Advance options (factory option)
|
Advance options (factory option)
|
||||||
======================================================
|
======================================================
|
||||||
@ -100,7 +101,7 @@ exit 1
|
|||||||
# http://mywiki.wooledge.org/BashFAQ/035
|
# http://mywiki.wooledge.org/BashFAQ/035
|
||||||
# http://wiki.bash-hackers.org/howto/getopts_tutorial
|
# http://wiki.bash-hackers.org/howto/getopts_tutorial
|
||||||
|
|
||||||
while getopts hc:C:o:v:B:A:baqtT:sS:M:lf:I: opt; do
|
while getopts hc:C:o:v:B:A:baqtT:sS:M:lf:I:k opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
I)
|
I)
|
||||||
if (( "$OPTARG" == 2 )); then
|
if (( "$OPTARG" == 2 )); then
|
||||||
@ -141,6 +142,9 @@ while getopts hc:C:o:v:B:A:baqtT:sS:M:lf:I: opt; do
|
|||||||
a)
|
a)
|
||||||
AboveValue=1
|
AboveValue=1
|
||||||
;;
|
;;
|
||||||
|
k)
|
||||||
|
showAB=0
|
||||||
|
;;
|
||||||
q)
|
q)
|
||||||
allowEcho=0
|
allowEcho=0
|
||||||
;;
|
;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user