Adding support for httpie 😄
This commit is contained in:
parent
2b0d1cf653
commit
9d66388cd2
|
@ -16,10 +16,12 @@ getConfiguredClient()
|
|||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -30,6 +32,7 @@ httpGet()
|
|||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
|
|
@ -17,29 +17,31 @@ getConfiguredClient()
|
|||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkInternet()
|
||||
{
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
checkInternet()
|
||||
{
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
update()
|
||||
{
|
||||
|
|
|
@ -15,16 +15,19 @@ checkOpenSSL()
|
|||
fi
|
||||
}
|
||||
|
||||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient()
|
||||
{
|
||||
if command -v curl &>/dev/null; then
|
||||
if command -v curl &>/dev/null; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -35,6 +38,7 @@ httpGet()
|
|||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
|
|
@ -9,25 +9,27 @@ configuredClient=""
|
|||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient()
|
||||
{
|
||||
if command -v curl &>/dev/null; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
return 1
|
||||
fi
|
||||
|
||||
if command -v curl &>/dev/null; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s -N "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
@ -55,7 +57,7 @@ checkTargetCurrency()
|
|||
echo "1"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
## Grabs the base currency from the user and validates it with all the possible currency
|
||||
|
@ -88,7 +90,7 @@ checkBase()
|
|||
# Matches the symbol to the appropriate ids regarding the API calling.
|
||||
transformBase()
|
||||
{
|
||||
case "$base" in
|
||||
case "$base" in
|
||||
"ETH") reqId="ethereum" ;;
|
||||
"BTC") reqId="bitcoin" ;;
|
||||
"XRP") reqId="ripple" ;;
|
||||
|
@ -167,10 +169,10 @@ convertCurrency()
|
|||
exchangeAmount=$(echo "$exchangeRate * $amount" | bc )
|
||||
exchangeTo=$(echo "$exchangeTo" | tr '[:lower:]' '[:upper:]')
|
||||
base=$(echo "$base" | tr '[:lower:]' '[:upper:]')
|
||||
|
||||
|
||||
cat <<EOF
|
||||
=========================
|
||||
| $base to $exchangeTo
|
||||
| $base to $exchangeTo
|
||||
| Rate: $exchangeRate
|
||||
| $base: $amount
|
||||
| $exchangeTo: $exchangeAmount
|
||||
|
@ -244,7 +246,7 @@ Supported Target Currencies:
|
|||
| CNY | EUR | GBP | HKD |
|
||||
| IDR | INR | JPY | KRW |
|
||||
| MXN | RUB | USD |
|
||||
_______________________
|
||||
_______________________
|
||||
|
||||
Examples:
|
||||
cryptocurrency BTC USD 12.35
|
||||
|
|
|
@ -10,30 +10,33 @@ currencyCodes=(AUD BGN BRL CAD CHF CNY CZK DKK
|
|||
JPY KRW MXN MYR NOK NZD PHP PLN
|
||||
RON RUB SEK SGD THB TRY USD ZAR)
|
||||
|
||||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient()
|
||||
{
|
||||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient()
|
||||
{
|
||||
if command -v curl &>/dev/null; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
checkValidCurrency()
|
||||
{
|
||||
|
|
|
@ -17,10 +17,12 @@ getConfiguredClient()
|
|||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -31,6 +33,7 @@ httpGet()
|
|||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
|
29
geo/geo
29
geo/geo
|
@ -8,24 +8,29 @@ currentVersion="1.16.2"
|
|||
configuredClient=""
|
||||
|
||||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient() {
|
||||
if command -v curl &>/dev/null; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
return 1
|
||||
fi
|
||||
getConfiguredClient()
|
||||
{
|
||||
if command -v curl &>/dev/null; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet() {
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
|
|
@ -9,16 +9,29 @@ detail=false
|
|||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient()
|
||||
{
|
||||
if command -v curl &>/dev/null ; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null ; then
|
||||
configuredClient="wget"
|
||||
elif command -v fetch &>/dev/null ; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
return 1
|
||||
fi
|
||||
if command -v curl &>/dev/null; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
getConfiguredPython()
|
||||
|
@ -43,17 +56,6 @@ if [[ $(uname) != "Darwin" ]]; then
|
|||
}
|
||||
fi
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
checkInternet()
|
||||
{
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
|
|
|
@ -6,12 +6,30 @@ configuredClient=""
|
|||
flagCount="0"
|
||||
declare -a simpleOperations=(simplify factor derive integrate zeroes roots tangent area cos sin tan arccos arcsin arctan abs log)
|
||||
|
||||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient()
|
||||
{
|
||||
if command -v curl &>/dev/null; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
@ -63,21 +81,6 @@ update()
|
|||
fi
|
||||
}
|
||||
|
||||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient()
|
||||
{
|
||||
if command -v curl &>/dev/null ; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null ; then
|
||||
configuredClient="wget"
|
||||
elif command -v fetch &>/dev/null ; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
validateExpression()
|
||||
{
|
||||
local parsedExpression # only used here
|
||||
|
|
30
qrify/qrify
30
qrify/qrify
|
@ -5,18 +5,34 @@ currentVersion="1.16.2"
|
|||
multiline="0" # flag that indicates multiline option
|
||||
|
||||
|
||||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient()
|
||||
{
|
||||
if command -v curl &> /dev/null; then
|
||||
if command -v curl &>/dev/null; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &> /dev/null; then
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool requires either curl or wget to be installed." >&2
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
update()
|
||||
{
|
||||
# Author: Alexander Epstein https://github.com/alexanderepstein
|
||||
|
@ -57,14 +73,6 @@ update()
|
|||
fi
|
||||
}
|
||||
|
||||
httpGet()
|
||||
{
|
||||
case "${configuredClient}" in
|
||||
curl) curl -A curl -s "$@";;
|
||||
wget) wget -qO- "$@";;
|
||||
esac
|
||||
}
|
||||
|
||||
makeqr()
|
||||
{
|
||||
input=$(echo ${input} | sed s/" "/%20/g ) ## replace all spaces in the sentence with HTML-encoded space %20
|
||||
|
|
24
short/short
24
short/short
|
@ -12,14 +12,27 @@ getConfiguredClient()
|
|||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
getConfiguredPython()
|
||||
{
|
||||
|
@ -43,15 +56,6 @@ if [[ $(uname) != "Darwin" ]];then
|
|||
}
|
||||
fi
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
checkInternet()
|
||||
{
|
||||
|
|
|
@ -13,16 +13,19 @@ checkOpenSSL()
|
|||
fi
|
||||
}
|
||||
|
||||
## This function determines which http get tool the system has installed and returns an error if there isnt one
|
||||
getConfiguredClient()
|
||||
{
|
||||
if command -v curl &>/dev/null; then
|
||||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -33,6 +36,7 @@ httpGet()
|
|||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
|
|
@ -12,14 +12,27 @@ getConfiguredClient()
|
|||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
getConfiguredPython()
|
||||
{
|
||||
if command -v python2 &>/dev/null; then
|
||||
|
@ -42,16 +55,6 @@ if [[ $(uname) != "Darwin" ]]; then
|
|||
}
|
||||
fi
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
checkInternet()
|
||||
{
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
|
|
25
taste/taste
25
taste/taste
|
@ -16,14 +16,27 @@ getConfiguredClient()
|
|||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
getConfiguredPython()
|
||||
{
|
||||
if command -v python2 &>/dev/null; then
|
||||
|
@ -46,16 +59,6 @@ if [[ $(uname) != "Darwin" ]]; then
|
|||
}
|
||||
fi
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
checkInternet()
|
||||
{
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
|
|
|
@ -11,10 +11,12 @@ getConfiguredClient()
|
|||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -25,6 +27,7 @@ httpGet()
|
|||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
@ -164,7 +167,7 @@ while getopts "cr:a:guvh" opt; do
|
|||
;;
|
||||
c) if [[ $flag == "" ]]; then
|
||||
flag="clear"
|
||||
else
|
||||
else
|
||||
echo "Error: all flags are mutually exclusive"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -13,10 +13,12 @@ getConfiguredClient()
|
|||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed."
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed\." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -27,6 +29,7 @@ httpGet()
|
|||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
|
|
@ -16,29 +16,32 @@ getConfiguredClient()
|
|||
configuredClient="curl"
|
||||
elif command -v wget &>/dev/null; then
|
||||
configuredClient="wget"
|
||||
elif command -v http &>/dev/null; then
|
||||
configuredClient="httpie"
|
||||
elif command -v fetch &>/dev/null; then
|
||||
configuredClient="fetch"
|
||||
else
|
||||
echo "Error: This tool reqires either curl, wget, or fetch to be installed." >&2
|
||||
echo "Error: This tool reqires either curl, wget, httpie or fetch to be installed\." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
checkInternet()
|
||||
{
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
## Allows to call the users configured client without if statements everywhere
|
||||
httpGet()
|
||||
{
|
||||
case "$configuredClient" in
|
||||
curl) curl -A curl -s "$@" ;;
|
||||
wget) wget -qO- "$@" ;;
|
||||
httpie) http -b GET "$@" ;;
|
||||
fetch) fetch -o "..." ;;
|
||||
esac
|
||||
}
|
||||
|
||||
checkInternet()
|
||||
{
|
||||
httpGet google.com > /dev/null 2>&1 || { echo "Error: no active internet connection" >&2; return 1; } # query google with a get request
|
||||
}
|
||||
|
||||
update()
|
||||
{
|
||||
# Author: Alexander Epstein https://github.com/alexanderepstein
|
||||
|
|
Loading…
Reference in New Issue