Only check internet when neccessary, speeds up options that dont need it
This commit is contained in:
parent
ca083193c8
commit
40a31f567d
|
@ -156,7 +156,7 @@ checkSpecialPage()
|
|||
}
|
||||
|
||||
getConfiguredClient || exit 1
|
||||
checkInternet || exit 1
|
||||
|
||||
|
||||
while getopts "ribuvhis" opt; do
|
||||
case "$opt" in
|
||||
|
@ -169,7 +169,9 @@ while getopts "ribuvhis" opt; do
|
|||
v) echo "Version $currentVersion"
|
||||
exit 0
|
||||
;;
|
||||
u) update
|
||||
u)
|
||||
checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
;;
|
||||
i) insensitive="i"
|
||||
|
@ -209,12 +211,14 @@ if [[ $# == 0 ]]; then
|
|||
usage
|
||||
exit 0
|
||||
elif [[ $1 == "update" ]]; then
|
||||
checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
elif [[ $1 == "help" || $1 == ":help" ]]; then ## shows the help and prevents the user from seeing cheat.sh/:help
|
||||
usage
|
||||
exit 0
|
||||
else
|
||||
checkInternet || exit 1
|
||||
if [[ $arg1 != $arg2 ]]; then ## if they equal each other that means there was no arg 2 supplied
|
||||
getCheatSheet $arg1 $arg2
|
||||
exit 0
|
||||
|
|
|
@ -226,7 +226,7 @@ EOF
|
|||
}
|
||||
|
||||
getConfiguredClient || exit 1
|
||||
checkInternet || exit 1
|
||||
|
||||
|
||||
while getopts "tspauvh" opt; do
|
||||
case "$opt" in
|
||||
|
@ -243,7 +243,8 @@ while getopts "tspauvh" opt; do
|
|||
v) echo "Version $currentVersion"
|
||||
exit 0
|
||||
;;
|
||||
u) update
|
||||
u) checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
;;
|
||||
:) echo "Option -$OPTARG requires an argument." >&2
|
||||
|
@ -256,6 +257,7 @@ if [[ $source == "1" && $all == "0" ]]; then { echo "Error: the -s flag only wor
|
|||
if [[ $configuredClient != "curl" ]]; then { echo "Error: to use cloudup without the -t option curl must be installed"; exit 1; }; fi ## we have to have the ability to delete an unique repo which is possible with curl -X DELETE
|
||||
if [[ $# == "1" ]]; then # check for keywords
|
||||
if [[ $1 == "update" ]]; then
|
||||
checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
elif [[ $1 == "help" ]]; then
|
||||
|
@ -264,6 +266,7 @@ if [[ $# == "1" ]]; then # check for keywords
|
|||
fi
|
||||
fi
|
||||
|
||||
checkInternet || exit 1
|
||||
if [[ $all == "0" ]]; then
|
||||
if [[ ($private == "0" && $tStamp == "0" && $1 != "")]]; then ## checking for an arguments after possible flags if so then run through the arguments (repositories) and back them up
|
||||
getGitHubUserInfo || exit 1
|
||||
|
|
|
@ -154,6 +154,7 @@ while getopts "huve:d:" opt; do ## alows for using options in bash
|
|||
fi
|
||||
;;
|
||||
u) getConfiguredClient || exit 1
|
||||
checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
;;
|
||||
|
|
|
@ -262,7 +262,7 @@ EOF
|
|||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
while getopts "uvh" opt; do
|
||||
case "$opt" in
|
||||
|
@ -275,7 +275,8 @@ while getopts "uvh" opt; do
|
|||
v) echo "Version $currentVersion"
|
||||
exit 0
|
||||
;;
|
||||
u) update
|
||||
u) 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
|
||||
;;
|
||||
:) echo "Option -$OPTARG requires an argument." >&2
|
||||
|
@ -285,6 +286,7 @@ while getopts "uvh" opt; do
|
|||
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
|
||||
|
@ -293,6 +295,7 @@ if [[ $# == 0 ]]; then
|
|||
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
|
||||
|
@ -306,10 +309,13 @@ elif [[ $# == "2" ]]; then
|
|||
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"
|
||||
fi
|
||||
|
|
|
@ -227,7 +227,7 @@ EOF
|
|||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
while getopts "uvh" opt; do
|
||||
case "$opt" in
|
||||
|
@ -240,7 +240,8 @@ while getopts "uvh" opt; do
|
|||
v) echo "Version $currentVersion"
|
||||
exit 0
|
||||
;;
|
||||
u) update
|
||||
u) 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
|
||||
;;
|
||||
:) echo "Option -$OPTARG requires an argument." >&2
|
||||
|
@ -250,6 +251,7 @@ while getopts "uvh" opt; do
|
|||
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
|
||||
|
@ -270,9 +272,12 @@ elif [[ $# == "2" ]]; then
|
|||
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
|
||||
convertCurrency
|
||||
exit 0
|
||||
else
|
||||
echo "Error: too many arguments."
|
||||
fi
|
||||
|
|
|
@ -208,7 +208,7 @@ EOF
|
|||
}
|
||||
|
||||
getConfiguredClient || exit 1
|
||||
checkInternet || exit 1
|
||||
|
||||
## getDirections Denver Boulder || exit 1
|
||||
## printDirections Denver Boulder || exit 1
|
||||
## getDirectionsMap Denver Boulder || exit 1
|
||||
|
@ -228,7 +228,8 @@ while getopts "drmuvh" opt; do
|
|||
v) echo "Version $currentVersion"
|
||||
exit 0
|
||||
;;
|
||||
u) update
|
||||
u) checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
;;
|
||||
:) echo "Option -$OPTARG requires an argument." >&2
|
||||
|
@ -244,6 +245,7 @@ if [[ $# == 0 ]]; then
|
|||
exit 0
|
||||
elif [[ $# == "1" ]]; then
|
||||
if [[ $1 == "update" ]]; then
|
||||
checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
elif [[ $1 == "help" ]]; then
|
||||
|
@ -251,7 +253,7 @@ elif [[ $# == "1" ]]; then
|
|||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
checkInternet || exit 1
|
||||
if [[ $directionsFlag == "0" && $staticMapFlag == "1" ]]; then
|
||||
checkImagemagick || exit 1
|
||||
getMapLocation || exit 1
|
||||
|
|
|
@ -174,11 +174,12 @@ EOF
|
|||
|
||||
if [[ $(uname) != "Darwin" ]]; then getConfiguredPython || exit 1; fi
|
||||
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
|
||||
|
||||
|
||||
while getopts 'ud:hv' flag; do
|
||||
case "${flag}" in
|
||||
u) update
|
||||
u) 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 ;;
|
||||
d) detail=true ;;
|
||||
h) usage
|
||||
|
@ -194,10 +195,12 @@ done
|
|||
if [[ $# == 0 ]]; then
|
||||
usage
|
||||
elif [[ $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
|
||||
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
|
||||
getMovieInfo "$@" || exit 1 ## exit if we return 1 (chances are movie was not found)
|
||||
printMovieInfo ## print out the data
|
||||
fi
|
||||
|
|
|
@ -166,7 +166,7 @@ Valid Symbols:
|
|||
EOF
|
||||
}
|
||||
|
||||
checkInternet || exit 1
|
||||
|
||||
getConfiguredClient || exit 1
|
||||
|
||||
while getopts "ur:vh" opt; do
|
||||
|
@ -192,13 +192,14 @@ done
|
|||
|
||||
if [[ $# == "0" ]]; then usage && exit 0
|
||||
elif [[ $# == "1" ]]; then
|
||||
if [[ $1 == "update" ]]; then update && exit 0 || exit 1
|
||||
if [[ $1 == "update" ]]; then checkInternet && update && exit 0 || exit 1
|
||||
elif [[ $1 == "help" ]]; then usage && exit 0 || exit 1
|
||||
else echo "Error: newton needs two arguments, operation and expression" && exit 1;fi
|
||||
elif [ $# -gt 3 ];then echo "Error: newton only accepts two arguments, operation and expression" && exit 1;fi
|
||||
|
||||
# flagCount helps us determine what argument to pass to the functions
|
||||
# flow: validateOperation, validateExpression, encodeEquation, getResponse, print Answer/Result
|
||||
checkInternet || exit 1
|
||||
if [[ $flagCount == "0" ]];then validateOperation $1 || exit 1
|
||||
elif [[ $flagCount == "1" ]];then validateOperation $2 || exit 1; fi
|
||||
if [[ $flagCount == "0" ]];then validateExpression $2 || exit 1
|
||||
|
|
|
@ -112,13 +112,13 @@ EOF
|
|||
}
|
||||
|
||||
getConfiguredClient || exit 1
|
||||
checkInternet || exit 1
|
||||
|
||||
|
||||
while getopts "m:hvu*:" option
|
||||
do
|
||||
case "${option}" in
|
||||
v) echo "Version ${currentVersion}" && exit 0 ;;
|
||||
u) update && exit 0 || exit 1 ;;
|
||||
u) checkInternet && update && exit 0 || exit 1 ;;
|
||||
h) usage && exit 0 ;;
|
||||
m) multiline="1" && echo "Error this is not a supported feature yet" && exit 1 ;;
|
||||
*) usage && exit 0 ;;
|
||||
|
@ -132,14 +132,17 @@ elif [[ ${1} == "help" ]]; then
|
|||
usage
|
||||
exit 0
|
||||
elif [[ ${1} == "update" ]]; then
|
||||
checkInternet || exit 1
|
||||
update || exit 1
|
||||
exit 0
|
||||
else
|
||||
if [[ ${multiline} == "0" ]]; then
|
||||
checkInternet || exit 1
|
||||
input=$(printf '%s ' "$@")
|
||||
makeqr || exit 1
|
||||
exit 0
|
||||
else
|
||||
checkInternet || exit 1
|
||||
makeMultiLineQr "${@:2}" || exit 1 ## if multiline that means a flag existed so start from the second argument
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -152,7 +152,7 @@ EOF
|
|||
|
||||
if [[ $(uname) != "Darwin" ]]; then getConfiguredPython || exit 1; fi
|
||||
getConfiguredClient || exit 1
|
||||
checkInternet || exit 1
|
||||
|
||||
|
||||
while getopts "uvh" opt; do
|
||||
case "$opt" in
|
||||
|
@ -165,7 +165,8 @@ while getopts "uvh" opt; do
|
|||
v) echo "Version $currentVersion"
|
||||
exit 0
|
||||
;;
|
||||
u) update
|
||||
u) checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
;;
|
||||
:) echo "Option -$OPTARG requires an argument." >&2
|
||||
|
@ -180,10 +181,12 @@ if [[ $# == 0 ]]; then
|
|||
exit 0
|
||||
elif [[ $# == "1" ]]; then
|
||||
if [[ $1 == "update" ]]; then
|
||||
checkInternet || exit 1
|
||||
update
|
||||
elif [[ $1 == "help" ]]; then
|
||||
usage
|
||||
else
|
||||
checkInternet || exit 1
|
||||
expandURL $1 || exit 1
|
||||
printResults
|
||||
fi
|
||||
|
|
|
@ -128,12 +128,13 @@ checkCiphers()
|
|||
|
||||
checkOpenSSL || exit 1
|
||||
getConfiguredClient || exit 1
|
||||
checkInternet || exit 1
|
||||
|
||||
|
||||
if [[ $# == "0" ]]; then
|
||||
usage
|
||||
exit 1
|
||||
elif [[ $1 == "update" ]]; then
|
||||
checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
elif [[ $1 == "help" ]]; then
|
||||
|
@ -150,7 +151,8 @@ while getopts "huvd:" opt; do ## alows for using options in bash
|
|||
DELAY=$OPTARG
|
||||
dFlag="1"
|
||||
;;
|
||||
u) update
|
||||
u) checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
;;
|
||||
h) usage
|
||||
|
@ -166,6 +168,7 @@ while getopts "huvd:" opt; do ## alows for using options in bash
|
|||
esac
|
||||
done
|
||||
|
||||
checkInternet || exit 1
|
||||
if [[ $dFlag == "1" ]]; then
|
||||
checkCiphers $3 || exit 1 # if dflag is present input will look like siteciphers -d 0.5 github.com making the website the third arg
|
||||
else
|
||||
|
|
|
@ -170,7 +170,7 @@ EOF
|
|||
|
||||
if [[ $(uname) != "Darwin" ]]; then getConfiguredPython || exit 1; fi
|
||||
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
|
||||
|
||||
|
||||
while getopts "uvh" opt; do
|
||||
case "$opt" in
|
||||
|
@ -183,7 +183,8 @@ while getopts "uvh" opt; do
|
|||
v) echo "Version $currentVersion"
|
||||
exit 0
|
||||
;;
|
||||
u) update
|
||||
u) checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
;;
|
||||
:) echo "Option -$OPTARG requires an argument." >&2
|
||||
|
@ -193,6 +194,7 @@ while getopts "uvh" opt; do
|
|||
done
|
||||
|
||||
if [[ $1 == "update" ]]; then
|
||||
checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
elif [[ $1 == "help" ]]; then
|
||||
|
@ -202,6 +204,7 @@ elif [[ $# == "0" ]]; then
|
|||
usage
|
||||
exit 0
|
||||
else
|
||||
checkInternet || exit 1
|
||||
getTicker "$@" # the company name might have spaces so passing in all args allows for this
|
||||
getStockInformation $symbol # based on the stock symbol exrapolated by the getTicker function get information on the stock
|
||||
printStockInformation # print this information out to the user in a human readable format
|
||||
|
|
|
@ -212,7 +212,7 @@ EOF
|
|||
fi
|
||||
if [[ $(uname) != "Darwin" ]]; then getConfiguredPython || exit 1; fi
|
||||
getConfiguredClient || exit 1
|
||||
checkInternet || exit 1
|
||||
|
||||
|
||||
while getopts "uvhis" opt; do
|
||||
case "$opt" in
|
||||
|
@ -225,7 +225,8 @@ while getopts "uvhis" opt; do
|
|||
v) echo "Version $currentVersion"
|
||||
exit 0
|
||||
;;
|
||||
u) update
|
||||
u) checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
;;
|
||||
i) if [[ $search == "0" ]]; then
|
||||
|
@ -252,10 +253,12 @@ done
|
|||
if [[ $# == 0 ]]; then
|
||||
usage
|
||||
elif [[ $1 == "update" ]]; then
|
||||
checkInternet || exit 1
|
||||
update
|
||||
elif [[ $1 == "help" ]]; then
|
||||
usage
|
||||
else
|
||||
checkInternet || exit 1
|
||||
if [[ $search == "0" ]]; then
|
||||
if [[ $info == "0" ]]; then
|
||||
getSimilar "$@" || exit 1 ## exit if we return 1 (chances are movie was not found)
|
||||
|
|
|
@ -250,4 +250,7 @@ elif $down;then
|
|||
getConfiguredDownloadClient || exit 1
|
||||
singleDownload "$inputFilePath" "$inputID" "$inputFileName" || exit 1
|
||||
exit 0
|
||||
else
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -122,7 +122,7 @@ EOF
|
|||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
while getopts "uvh" opt; do
|
||||
case "$opt" in
|
||||
|
@ -135,7 +135,8 @@ while getopts "uvh" opt; do
|
|||
v) echo "Version $currentVersion"
|
||||
exit 0
|
||||
;;
|
||||
u) update
|
||||
u) 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 1
|
||||
exit 0
|
||||
;;
|
||||
:) echo "Option -$OPTARG requires an argument." >&2
|
||||
|
@ -145,36 +146,44 @@ while getopts "uvh" opt; do
|
|||
done
|
||||
|
||||
if [[ $# == "0" ]]; then
|
||||
getIPWeather
|
||||
checkInternet || exit 1
|
||||
getIPWeather || exit 1
|
||||
exit 0
|
||||
elif [[ $1 == "help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
elif [[ $1 == "update" ]]; then
|
||||
update
|
||||
elif [[ $1 == "m" ]]; then
|
||||
getIPWeather "?m"
|
||||
checkInternet || exit 1
|
||||
update || exit 1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
checkInternet || exit 1
|
||||
if [[ $1 == "m" ]]; then
|
||||
getIPWeather "?m" || exit 1
|
||||
elif [[ "${@: -1}" == "m" ]];then
|
||||
args=$( echo "${@:1:(($# - 1))}" ?m | sed s/" "//g)
|
||||
getLocationWeather $args
|
||||
getLocationWeather $args || exit 1
|
||||
elif [[ $1 == "M" ]]; then
|
||||
getIPWeather "?M"
|
||||
getIPWeather "?M" || exit 1
|
||||
elif [[ "${@: -1}" == "M" ]];then
|
||||
args=$( echo "${@:1:(($# - 1))}" ?M | sed s/" "//g)
|
||||
getLocationWeather $args
|
||||
getLocationWeather $args || exit 1
|
||||
elif [[ $1 == "mM" || $1 == "Mm" ]]; then
|
||||
getIPWeather "?m?M"
|
||||
getIPWeather "?m?M" || exit 1
|
||||
elif [[ "${@: -1}" == "mM" || "${@:-1}" == "Mm" ]];then
|
||||
args=$( echo "${@:1:(($# - 1))}" ?m?M | sed s/" "//g)
|
||||
getLocationWeather $args
|
||||
getLocationWeather $args || exit 1
|
||||
elif [[ $1 == "iM" || $1 == "Mi" ]]; then
|
||||
getIPWeather "?u?M"
|
||||
getIPWeather "?u?M" || exit 1
|
||||
elif [[ "${@: -1}" == "iM" || "${@:-1}" == "Mi" ]];then
|
||||
args=$( echo "${@:1:(($# - 1))}" ?u?M | sed s/" "//g)
|
||||
getLocationWeather $args
|
||||
getLocationWeather $args || exit 1
|
||||
elif [[ $1 == "i" ]]; then
|
||||
getIPWeather "?u"
|
||||
getIPWeather "?u" || exit 1
|
||||
elif [[ "${@: -1}" == "i" ]];then
|
||||
args=$( echo "${@:1:(($# - 1))}" ?u | sed s/" "//g)
|
||||
getLocationWeather $args
|
||||
getLocationWeather $args || exit 1
|
||||
else
|
||||
getLocationWeather "$@"
|
||||
getLocationWeather "$@" || exit 1
|
||||
fi
|
||||
|
|
|
@ -161,7 +161,7 @@ EOF
|
|||
}
|
||||
|
||||
getConfiguredClient || exit 1
|
||||
checkInternet || exit 1
|
||||
|
||||
|
||||
while getopts "vuc:s:h*:" option; do
|
||||
case "${option}" in
|
||||
|
@ -182,7 +182,7 @@ while getopts "vuc:s:h*:" option; do
|
|||
fi
|
||||
;;
|
||||
h) usage && exit 0 ;;
|
||||
u) update && exit 0 ;;
|
||||
u) checkInternet && update && exit 0 || exit 1;;
|
||||
v) echo "Version $currentVersion" && exit 0 ;;
|
||||
*) usage && exit 0 ;;
|
||||
esac
|
||||
|
@ -195,15 +195,19 @@ elif [[ $1 == "help" ]]; then
|
|||
usage
|
||||
exit 0
|
||||
elif [[ $1 == "update" ]]; then
|
||||
checkInternet || exit 1
|
||||
update
|
||||
exit 0
|
||||
elif [[ $flag == "search" ]]; then
|
||||
checkInternet || exit 1
|
||||
getConfiguredPlayer || exit 1
|
||||
searchview || exit 1
|
||||
elif [[ $flag == "channel" ]]; then
|
||||
checkInternet || exit 1
|
||||
getConfiguredPlayer || exit 1
|
||||
channelview || exit 1
|
||||
else
|
||||
checkInternet || exit 1
|
||||
search=$(printf '%s ' "$@")
|
||||
getConfiguredPlayer || exit 1
|
||||
searchview || exit 1
|
||||
|
|
Loading…
Reference in New Issue