mirror of
https://github.com/alexanderepstein/Bash-Snippets
synced 2018-11-08 02:59:35 +01:00
Adding help to each tool
This commit is contained in:
parent
3d2540b42a
commit
5b8479552b
25
crypt/crypt
25
crypt/crypt
@ -58,7 +58,19 @@ update()
|
||||
|
||||
}
|
||||
|
||||
while getopts "uve:d:" opt; do ## alows for using options in bash
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Crypt tool"
|
||||
echo "Usage: crypt [flag] [inputFile] [outputFile]"
|
||||
echo " -e Encrypt the inputFile and store it in the outputFile"
|
||||
echo " -d Decrypt the inputFile and store it in the outputFile"
|
||||
echo " -u Update Bash-Snippet Tools"
|
||||
echo " -h Show the help"
|
||||
echo " -v Get the tool version"
|
||||
}
|
||||
|
||||
while getopts "huve:d:" opt; do ## alows for using options in bash
|
||||
case $opt in
|
||||
e) ## when trying to encrypt run this
|
||||
if [[ $# -ne 3 ]]; then
|
||||
@ -82,6 +94,10 @@ while getopts "uve:d:" opt; do ## alows for using options in bash
|
||||
update
|
||||
exit 0
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
v)
|
||||
echo "Version $currentVersion"
|
||||
exit 0
|
||||
@ -93,7 +109,12 @@ while getopts "uve:d:" opt; do ## alows for using options in bash
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $1 == "update" ]];then
|
||||
if [[ $# == 0 ]]; then
|
||||
usage
|
||||
elif [[ $1 == "update" ]];then
|
||||
update
|
||||
exit 0
|
||||
elif [[ $1 == "help" ]];then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
@ -174,16 +174,27 @@ update()
|
||||
|
||||
}
|
||||
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Currency tool"
|
||||
echo "Usage: currency or currency [flag] or currency [base] [exchangeTo] [amount]"
|
||||
echo " -u Update Bash-Snippet Tools"
|
||||
echo " -h Show the help"
|
||||
echo " -v Get the tool version"
|
||||
}
|
||||
|
||||
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 "uv" opt; do
|
||||
while getopts "uvh" opt; do
|
||||
case $opt in
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
h)
|
||||
help
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
v)
|
||||
echo "Version $currentVersion"
|
||||
@ -209,6 +220,8 @@ if [[ $# == 0 ]]; then
|
||||
elif [[ $# == "1" ]]; then
|
||||
if [[ $1 == "update" ]];then
|
||||
update
|
||||
elif [[ $1 == "help" ]]; then
|
||||
usage
|
||||
else
|
||||
echo "Not a valid argument"
|
||||
fi
|
||||
|
@ -94,16 +94,26 @@ update()
|
||||
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Movies tool"
|
||||
echo "Usage: movies [flag] or movies [movieToSearch]"
|
||||
echo " -u Update Bash-Snippet Tools"
|
||||
echo " -h Show the help"
|
||||
echo " -v Get the tool version"
|
||||
}
|
||||
|
||||
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 "uv" opt; do
|
||||
while getopts "uvh" opt; do
|
||||
case $opt in
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
h)
|
||||
help
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
v)
|
||||
echo "Version $currentVersion"
|
||||
@ -120,8 +130,12 @@ while getopts "uv" opt; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $1 == "update" ]];then
|
||||
if [[ $# == 0 ]]; then
|
||||
usage
|
||||
elif [[ $1 == "update" ]];then
|
||||
update
|
||||
elif [[ $1 == "help" ]];then
|
||||
usage
|
||||
else
|
||||
getMovieInfo $1 $2 $3 $4 $5 $6 $7 $8 $9 || exit 1 ## exit if we return 1 (chances are movie was not found)
|
||||
printMovieInfo ## print out the data
|
||||
|
@ -107,18 +107,26 @@ update()
|
||||
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Stocks tool"
|
||||
echo "Usage: stocks [flag or company]"
|
||||
echo " -u Update Bash-Snippet Tools"
|
||||
echo " -h Show the help"
|
||||
echo " -v Get the tool version"
|
||||
}
|
||||
|
||||
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 "uv" opt; do
|
||||
while getopts "uvh" opt; do
|
||||
case $opt in
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
h)
|
||||
help
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
v)
|
||||
@ -139,8 +147,10 @@ done
|
||||
|
||||
if [[ $1 == "update" ]];then
|
||||
update
|
||||
elif [[ $1 == "help" ]];then
|
||||
usage
|
||||
elif [[ $# == "0" ]];then
|
||||
echo "Error: requires an argument either stocks [company] or stocks [stock symbol]"
|
||||
usage
|
||||
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
|
||||
getStockInformation $symbol # based on the stock symbol exrapolated by the getTicker function get information on the stock
|
||||
|
@ -75,19 +75,33 @@ update()
|
||||
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Weather tool"
|
||||
echo "Usage: weather or weather [flag] or weather [country] or weather [city] [state]"
|
||||
echo " weather [i] get weather in imperial units"
|
||||
echo " weather [m] get weather in metric units"
|
||||
echo " weather [Moon] grabs the phase of the moon"
|
||||
echo " -u Update Bash-Snippet Tools"
|
||||
echo " -h Show the help"
|
||||
echo " -v Get the tool version"
|
||||
}
|
||||
|
||||
|
||||
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 "uv" opt; do
|
||||
while getopts "uvh" opt; do
|
||||
case $opt in
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
h)
|
||||
help
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
v)
|
||||
echo "Version $currentVersion"
|
||||
@ -106,6 +120,8 @@ done
|
||||
|
||||
if [[ $# == "0" ]]; then
|
||||
getIPWeather
|
||||
elif [[ $1 == "help" ]];then
|
||||
usage
|
||||
elif [[ $1 == "update" ]]; then
|
||||
update
|
||||
elif [[ $1 == "m" ]]; then
|
||||
|
Loading…
Reference in New Issue
Block a user