echo -e "Option: \"-$OPTARG\" requires an argument\n"&&help
exit
;;
b)
re='^[0-9]+$'
number_of_backups=$OPTARG
! [[$OPTARG=~ $re]]&&echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2&&exit
[["$number_of_backups" -le 0]]&&echo"Error: Number of backups is required to be at least 1"&&exit
;;
i)
ignore+=("$OPTARG")
;;
t)
re='^[0-9]+$'
timeout=$OPTARG
! [[$timeout=~ $re]]&&echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2&&exit
;;
s)
sync="true"
;;
U)
update_all_apps="true"
;;
u)
update_apps="true"
;;
p)
prune="true"
;;
v)
verbose="true"
;;
*)
echo -e "Invalid Option \"--$OPTARG\"\n"&&help
exit
;;
esac
done
fi
## Exit if incompatable functions are called
[["$update_all_apps"=="true"&&"$update_apps"=="true"]]&&echo -e "-U and -u cannot BOTH be called"&&exit
## Exit if unsafe combinations are used
# Restore and update right after eachother, might cause super weird issues tha are hard to bugtrace
[[("$update_all_apps"=="true"||"$update_apps"=="true")&&("$restore"=="true")]]&&echo -e "Update and Restore cannot both be done in the same run..."&&exit
# Backup Deletion is generally considered to be a "once in a while" thing and not great to sync with automated updates for that reason
[[("$update_all_apps"=="true"||"$update_apps"=="true")&&("$deleteBackup"=="true")]]&&echo -e "Update Backup-Deletion cannot both be done in the same run..."&&exit
# Backup Deletion is generally considered to be a "once in a while" thing and not great to sync with automated updates for that reason
[[("$update_all_apps"=="true"||"$update_apps"=="true")&&("$deleteBackup"=="true")]]&&echo -e "Update and Backup-Deletion cannot both be done in the same run..."&&exit
# Backup listing is a printout, which would either clutter the output or be already outdated when combined with backup
[[("$update_all_apps"=="true"||"$update_apps"=="true")&&("$listBackups"=="true")]]&&echo -e "Update and Listing Backups cannot both be done in the same run..."&&exit
# Backup backup would be done after a backup is restored, which would lead to a backup that is... the same as the one restored...
[[("$restore"=="true"&&"$number_of_backups" -ge 1)]]&&echo -e "Restoring a backup and making a backup cannot both be done in the same run..."&&exit
# While technically possible, this is asking for user error... where a user by habit mistakes one prompt, for the other.
[[("$restore"=="true"&&"$deleteBackup"=="true")]]&&echo -e "restoring a backup and deleting a backup cannot both be done in the same run..."&&exit