Changed $1 $2 $3 etc to just $@ (#28)
* Now using $@ for readability and maintainability
This commit is contained in:
parent
bf27d72057
commit
88e70d61f2
|
@ -47,7 +47,7 @@ checkInternet()
|
||||||
getMovieInfo()
|
getMovieInfo()
|
||||||
{
|
{
|
||||||
apiKey=946f500a # try not to abuse this it is a key that came from the ruby-scripts repo I link to.
|
apiKey=946f500a # try not to abuse this it is a key that came from the ruby-scripts repo I link to.
|
||||||
movie=$(echo $1 $2 $3 $4 $5 $6 $7 $8 $9 | tr " " + ) ## format the inputs to use for the api
|
movie=$(echo $@ | tr " " + ) ## format the inputs to use for the api
|
||||||
export PYTHONIOENCODING=utf8 #necessary for python2 in some cases
|
export PYTHONIOENCODING=utf8 #necessary for python2 in some cases
|
||||||
movieInfo=$(httpGet "http://www.omdbapi.com/?t=$movie&apikey=$apiKey") > /dev/null # query the server and get the JSON response
|
movieInfo=$(httpGet "http://www.omdbapi.com/?t=$movie&apikey=$apiKey") > /dev/null # query the server and get the JSON response
|
||||||
checkResponse=$(echo $movieInfo | python2 -c "import sys, json; print json.load(sys.stdin)['Response']")
|
checkResponse=$(echo $movieInfo | python2 -c "import sys, json; print json.load(sys.stdin)['Response']")
|
||||||
|
@ -167,6 +167,6 @@ elif [[ $1 == "update" ]];then
|
||||||
elif [[ $1 == "help" ]];then
|
elif [[ $1 == "help" ]];then
|
||||||
usage
|
usage
|
||||||
else
|
else
|
||||||
getMovieInfo $1 $2 $3 $4 $5 $6 $7 $8 $9 || exit 1 ## exit if we return 1 (chances are movie was not found)
|
getMovieInfo $@ || exit 1 ## exit if we return 1 (chances are movie was not found)
|
||||||
printMovieInfo ## print out the data
|
printMovieInfo ## print out the data
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -183,7 +183,7 @@ elif [[ $# == "0" ]];then
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
getTicker $1 $2 $3 $4 $5 $6 $7 $8 $9 # the company name might have spaces so passing in all args allows for this
|
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
|
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
|
printStockInformation # print this information out to the user in a human readable format
|
||||||
exit 0
|
exit 0
|
||||||
|
|
10
taste/taste
10
taste/taste
|
@ -91,7 +91,7 @@ update()
|
||||||
getSimilar()
|
getSimilar()
|
||||||
{
|
{
|
||||||
export PYTHONIOENCODING=utf8 #necessary for python2 in some cases
|
export PYTHONIOENCODING=utf8 #necessary for python2 in some cases
|
||||||
media=$( echo "$1 $2 $3 $4 $5 $6 $7 $8" | tr " " + )
|
media=$( echo "$@" | tr " " + )
|
||||||
response=$(httpGet "https://tastedive.com/api/similar?q=$media&k=$apiKey&info=$info")
|
response=$(httpGet "https://tastedive.com/api/similar?q=$media&k=$apiKey&info=$info")
|
||||||
## Extrapolate the information by parsing the JSON
|
## Extrapolate the information by parsing the JSON
|
||||||
nameOne=$(echo $response | python2 -c "import sys, json; print json.load(sys.stdin)['Similar']['Results'][0]['Name']" 2> /dev/null || { echo "Error: Did you search a valid item?"; return 1; } )
|
nameOne=$(echo $response | python2 -c "import sys, json; print json.load(sys.stdin)['Similar']['Results'][0]['Name']" 2> /dev/null || { echo "Error: Did you search a valid item?"; return 1; } )
|
||||||
|
@ -112,7 +112,7 @@ getSimilar()
|
||||||
getInfo()
|
getInfo()
|
||||||
{
|
{
|
||||||
export PYTHONIOENCODING=utf8 #necessary for python2 in some cases
|
export PYTHONIOENCODING=utf8 #necessary for python2 in some cases
|
||||||
media=$( echo "$1 $2 $3 $4 $5 $6 $7 $8" | tr " " + )
|
media=$( echo "$@" | tr " " + )
|
||||||
response=$(httpGet "https://tastedive.com/api/similar?q=$media&k=$apiKey&info=$info")
|
response=$(httpGet "https://tastedive.com/api/similar?q=$media&k=$apiKey&info=$info")
|
||||||
name=$(echo $response | python2 -c "import sys, json; print json.load(sys.stdin)['Similar']['Info'][0]['Name']")
|
name=$(echo $response | python2 -c "import sys, json; print json.load(sys.stdin)['Similar']['Info'][0]['Name']")
|
||||||
type=$(echo $response | python2 -c "import sys, json; print json.load(sys.stdin)['Similar']['Info'][0]['Type']")
|
type=$(echo $response | python2 -c "import sys, json; print json.load(sys.stdin)['Similar']['Info'][0]['Type']")
|
||||||
|
@ -238,14 +238,14 @@ elif [[ $1 == "help" ]];then
|
||||||
else
|
else
|
||||||
if [[ $search == "0" ]];then
|
if [[ $search == "0" ]];then
|
||||||
if [[ $info == "0" ]];then
|
if [[ $info == "0" ]];then
|
||||||
getSimilar $1 $2 $3 $4 $5 $6 $7 $8 || exit 1 ## exit if we return 1 (chances are movie was not found)
|
getSimilar $@ || exit 1 ## exit if we return 1 (chances are movie was not found)
|
||||||
printResults
|
printResults
|
||||||
else
|
else
|
||||||
getSimilar $2 $3 $4 $5 $6 $7 $8 $9 || exit 1
|
getSimilar $@ || exit 1
|
||||||
printResults
|
printResults
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
getInfo $2 $3 $4 $5 $6 $7 $8 $9 || exit 1 ## exit if we return 1 (chances are movie was not found)
|
getInfo ${@:2} || exit 1 ## exit if we return 1 (chances are movie was not found)
|
||||||
printInfo
|
printInfo
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -49,7 +49,8 @@ getIPWeather()
|
||||||
|
|
||||||
getLocationWeather()
|
getLocationWeather()
|
||||||
{
|
{
|
||||||
httpGet $locale.wttr.in/$1+$2+$3+$4
|
args=$(echo $@ | tr " " + )
|
||||||
|
httpGet $locale.wttr.in/${args}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkInternet()
|
checkInternet()
|
||||||
|
@ -158,5 +159,5 @@ elif [[ $1 == "m" ]]; then
|
||||||
elif [[ $1 == "i" ]]; then
|
elif [[ $1 == "i" ]]; then
|
||||||
getIPWeather "?u"
|
getIPWeather "?u"
|
||||||
else
|
else
|
||||||
getLocationWeather $1 $2 $3 $4
|
getLocationWeather $@
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue