mirror of
https://github.com/arkenfox/user.js.git
synced 2025-05-03 23:43:40 +02:00
don't require value for all arguments
This commit is contained in:
parent
f43efcb670
commit
c3e652574e
1 changed files with 49 additions and 44 deletions
93
updater.sh
93
updater.sh
|
@ -39,18 +39,14 @@ ff_profile="$(dirname "${sfp}")"
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo -e ${BLUE}"\nUsage: $0 [ -u UPDATE ] [ -c CONFIRM ] [ -o OVERRIDE]\n"${NC} 1>&2 # Echo usage string to standard error
|
echo -e ${BLUE}"\nUsage: $0 [-h] [-u] [-d] [-s] [-n] [-o OVERRIDE]\n"${NC} 1>&2 # Echo usage string to standard error
|
||||||
echo -e "Optional Arguments:"
|
echo -e "Optional Arguments:"
|
||||||
echo -e "\t -u UPDATE"
|
echo -e "\t-h,\t\t Show this help message and exit."
|
||||||
echo -e "\t\t check (default): Check for availabe updates to updater.sh and confirm installation/execution"
|
echo -e "\t-u,\t\t Update updater.sh and execute silently. Do not seek confirmation."
|
||||||
echo -e "\t\t yes: Check for availabe updates and install/execute silently"
|
echo -e "\t-d,\t\t Do not look for updates to updater.sh."
|
||||||
echo -e "\t\t no: Do not look for updates to updater.sh"
|
echo -e "\t-s,\t\t Silently update user.js. Do not seek confirmation."
|
||||||
echo -e "\t -c CONFIRM"
|
echo -e "\t-o OVERRIDE,\t Filename or path to overrides file (if different than user-overrides.js)."
|
||||||
echo -e "\t\t yes (default): Ask for confirmation to update user.js after viewing versions"
|
echo -e "\t-n,\t\t Do not append any overrides, evein if user-overrides.js exists."
|
||||||
echo -e "\t\t no: Silently update user.js"
|
|
||||||
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 none: Do not append any overrides, evein if user-overrides.js exists"
|
|
||||||
echo -e
|
echo -e
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -63,45 +59,54 @@ legacy_argument () {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Arguement defaults
|
# Arguement defaults
|
||||||
UPDATE="check"
|
UPDATE="check"
|
||||||
CONFIRM="yes"
|
CONFIRM="yes"
|
||||||
OVERRIDE="user-overrides.js"
|
OVERRIDE="user-overrides.js"
|
||||||
|
|
||||||
# Display usage if first arguement is -help or --help
|
|
||||||
if [ $1 = "--help" ] || [ $1 = "-help" ]; then
|
if [ $# != 0 ]; then
|
||||||
usage
|
# Display usage if first arguement is -help or --help
|
||||||
elif [ $1 = "-donotupdate" ]; then
|
if [ $1 = "--help" ] || [ $1 = "-help" ]; then
|
||||||
UPDATE="no"
|
usage
|
||||||
legacy_argument $1
|
elif [ $1 = "-donotupdate" ]; then
|
||||||
elif [ $1 = "-update" ]; then
|
UPDATE="no"
|
||||||
UPDATE="yes"
|
legacy_argument $1
|
||||||
legacy_argument $1
|
elif [ $1 = "-update" ]; then
|
||||||
else
|
UPDATE="yes"
|
||||||
# Get user set arguements
|
legacy_argument $1
|
||||||
while getopts "u:c:o:" options; do
|
else
|
||||||
case "${options}" in
|
while getopts ":hudso:n" opt; do
|
||||||
u)
|
case $opt in
|
||||||
UPDATE=${OPTARG}
|
h)
|
||||||
if [ $CONFIRM != "check" ] && [ $CONFIRM != "yes" ] && [ $CONFIRM != "no" ]; then
|
|
||||||
echo -e ${RED}"\nError: -u must be one of [check, yes, no]"${NC}
|
|
||||||
usage
|
usage
|
||||||
fi
|
;;
|
||||||
;;
|
u)
|
||||||
c)
|
UPDATE="yes"
|
||||||
CONFIRM=${OPTARG}
|
;;
|
||||||
if [ $CONFIRM != "yes" ] && [ $CONFIRM != "no" ]; then
|
d)
|
||||||
echo -e ${RED}"\nError: -c must be one of [yes, no]"${NC}
|
UPDATE="no"
|
||||||
|
;;
|
||||||
|
s)
|
||||||
|
CONFIRM="no"
|
||||||
|
;;
|
||||||
|
o)
|
||||||
|
OVERRIDE=${OPTARG}
|
||||||
|
;;
|
||||||
|
n)
|
||||||
|
OVERRIDE="none"
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo -e ${RED}"\nInvalid option: -$OPTARG"${NC} >&2
|
||||||
usage
|
usage
|
||||||
fi
|
;;
|
||||||
;;
|
esac
|
||||||
o)
|
done
|
||||||
OVERRIDE=${OPTARG}
|
fi
|
||||||
esac
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# File Handeling #
|
# File Handeling #
|
||||||
#########################
|
#########################
|
||||||
|
@ -234,7 +239,7 @@ update_updater () {
|
||||||
# Backup current updater, execute latest version
|
# Backup current updater, execute latest version
|
||||||
backup_file updater.sh
|
backup_file updater.sh
|
||||||
chmod +x updater.sh
|
chmod +x updater.sh
|
||||||
./updater.sh -u no
|
./updater.sh "$@"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue