Adding extras to the update pipeline and adding usage to maps

This commit is contained in:
Alex Epstein 2017-07-24 20:49:49 -04:00
parent cf41151e09
commit 9a6ded3f4a
2 changed files with 56 additions and 1 deletions

View File

@ -186,6 +186,28 @@ getStaticMap()
rm -rf ~/temp > /dev/null || return 1
}
usage()
{
cat <<EOF
Maps
Description: Get directions between locations, generate static maps of locations, and generate route maps for directions.
Usage: maps [flags]
-u Update Bash-Snippet Tools
-d Get directions from a location to a destination
-r Generate route map (must be used with the -d flag)
-m Generate static map
* By itself will ask for a location to generate a map
* In conjunction with the -d flag will generate maps for the start location and the destination
-h Show the help
-v Get the tool version
Examples:
maps -d
maps -d -r -m
maps -m
maps -d -m
EOF
}
getConfiguredClient || exit 1
checkInternet || exit 1
## getDirections Denver Boulder || exit 1
@ -228,6 +250,8 @@ while getopts "drmuvh" opt; do
esac
done
if [[ $directionsMapFlag == "1" && $directionsFlag == "0" ]];then { echo "Error the -r flag only works in conjunction with the -d flag."; exit 1; };fi
if [[ $# == 0 ]]; then
usage
exit 0
@ -253,6 +277,6 @@ elif [[ $directionsFlag == "1" ]];then
if [[ $directionsMapFlag == "1" ]];then getDirectionsMap $fromLocation $toLocation || exit 1;fi
if [[ $staticMapFlag = "1" ]];then
echo "Generating static map for $unformattedFromLocation" && getStaticMap $fromLocation || exit 1
echo "Generating static map for $unformattedToLocation" && getStaticMap $toLocation || exit 1
echo "Generating static map for $unformattedToLocation" && getStaticMap $toLocation || exit 1
fi
fi

View File

@ -2,6 +2,8 @@
# Author: Alexander Epstein https://github.com/alexanderepstein
currentVersion="1.14.3"
declare -a tools=(currency stocks weather crypt movies taste short geo cheat ytview cloudup qrify siteciphers todo)
declare -a extraLinuxTools=(maps)
declare -a extraDarwinTools
usedGithubInstallMethod="0"
askInstall()
@ -31,6 +33,23 @@ updateTool()
fi
}
extraUpdateTool()
{
if [[ -f /usr/local/bin/$1 ]];then
usedGithubInstallMethod="1"
cd extras || return 1
cd $2 || return 1
cd $1 || return 1
echo -n "Installing $1: "
chmod a+x $1
cp $1 /usr/local/bin > /dev/null 2>&1 || { echo "Failure"; echo "Error copying file, try running install script as sudo"; exit 1; }
echo "Success"
cd .. || return 1
cd .. || return 1
cd .. || return 1
fi
}
singleInstall()
{
cd $1 || exit 1
@ -60,6 +79,18 @@ elif [[ $1 == "update" ]]; then
do
updateTool $tool || exit 1
done
if [[ $(uname -s) == "Linux" ]];then
for tool in "${extraLinuxTools[@]}"
do
extraUpdateTool $tool Linux || exit 1
done
fi
if [[ $(uname) == "Darwin" ]];then
for tool in "${extraDarwinTools[@]}"
do
extraUpdateTool $tool Darwin || exit 1
done
fi
if [[ $usedGithubInstallMethod == "1" ]]; then copyManpage || exit 1
else { echo "It appears you have installed bash-snippets through a package manager, you must update it with the respective package manager."; exit 0; } ;fi
elif [[ $1 == "all" ]];then