support depracated args

This commit is contained in:
overdodactyl 2018-11-19 15:01:50 -07:00
parent a4fc404560
commit f43efcb670

View file

@ -11,6 +11,7 @@
######################### #########################
# Base variables # # Base variables #
######################### #########################
update_pref=${1:--ask} update_pref=${1:--ask}
RED='\033[0;31m' RED='\033[0;31m'
BLUE='\033[0;34m' BLUE='\033[0;34m'
@ -34,12 +35,12 @@ if [ -z "$sfp" ]; then sfp=${BASH_SOURCE[0]}; fi
ff_profile="$(dirname "${sfp}")" ff_profile="$(dirname "${sfp}")"
######################### #########################
# Arguements # # Arguments #
######################### #########################
usage() { usage() {
echo -e ${BLUE}"\nUsage: $0 [ -u UPDATE ] [ -t CONFIRM ]\n"${NC} 1>&2 # Echo usage string to standard error echo -e ${BLUE}"\nUsage: $0 [ -u UPDATE ] [ -c CONFIRM ] [ -o OVERRIDE]\n"${NC} 1>&2 # Echo usage string to standard error
echo -e "Optional Arguements:" echo -e "Optional Arguments:"
echo -e "\t -u UPDATE" echo -e "\t -u UPDATE"
echo -e "\t\t check (default): Check for availabe updates to updater.sh and confirm installation/execution" echo -e "\t\t check (default): Check for availabe updates to updater.sh and confirm installation/execution"
echo -e "\t\t yes: Check for availabe updates and install/execute silently" echo -e "\t\t yes: Check for availabe updates and install/execute silently"
@ -49,23 +50,35 @@ usage() {
echo -e "\t\t no: Silently update user.js" echo -e "\t\t no: Silently update user.js"
echo -e "\t -o OVERRIDE" echo -e "\t -o OVERRIDE"
echo -e "\t\t filename: Filename or path to append to user.js (default: user-overrides.js)" echo -e "\t\t filename: Filename or path to append to user.js (default: user-overrides.js)"
echo -e "\t\t none: Do not append any overrides" echo -e "\t\t none: Do not append any overrides, evein if user-overrides.js exists"
echo -e echo -e
exit 1 exit 1
} }
legacy_argument () {
arg=$1
echo -e ${ORANGE}"\nWarning: command line arguments have changed."
echo -e "${arg} has been deprecated and may not work in the future.\n"
echo -e "Please view the new options using the --help argument."${NC}
}
# Arguement defaults
UPDATE="check"
CONFIRM="yes"
OVERRIDE="user-overrides.js"
# Display usage if first arguement is -help or --help # Display usage if first arguement is -help or --help
if [ $1 = "--help" ] || [ $1 = "-help" ]; then if [ $1 = "--help" ] || [ $1 = "-help" ]; then
usage usage
fi elif [ $1 = "-donotupdate" ]; then
UPDATE="no"
# Arguement defaults legacy_argument $1
UPDATE="check" elif [ $1 = "-update" ]; then
CONFIRM="yes" UPDATE="yes"
OVERRIDE="user-overrides.js" legacy_argument $1
else
# Get user set arguements # Get user set arguements
while getopts "u:c:o:" options; do while getopts "u:c:o:" options; do
case "${options}" in case "${options}" in
u) u)
UPDATE=${OPTARG} UPDATE=${OPTARG}
@ -84,7 +97,8 @@ while getopts "u:c:o:" options; do
o) o)
OVERRIDE=${OPTARG} OVERRIDE=${OPTARG}
esac esac
done done
fi