diff --git a/.gitignore b/.gitignore index 34327d5..0418c82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ * !h2mm !install.sh -!README.md \ No newline at end of file +!README.md +!version \ No newline at end of file diff --git a/README.md b/README.md index eb5bed1..58b52bf 100644 --- a/README.md +++ b/README.md @@ -89,8 +89,6 @@ You can use the short form of the commands to save some time. The shortcuts are: You can export all installed mods to a zip file and import mods from the same file. This can be useful for sharing mods with others or for backing up your mods. The zip file will be saved in the current directory. -This will serve as either a backup or a way to have multiple mod setups. - ```bash h2mm export modpack1.zip h2mm import modpack2.zip @@ -115,6 +113,8 @@ Feel free to contribute to this project by creating a pull request or opening an ## Planned features - [ ] ! Enable/disable mods +- [ ] ! Provide fixes for breaking updates +- [ ] ! Auto update mods - [ ] !! Easier way to change mod presets - [ ] !! Change to `.tar.xz` for exporting and importing - [ ] !!! Find a way to make use of `manifest.json` and simplify installing variants diff --git a/h2mm b/h2mm index 744a302..05c9f0d 100755 --- a/h2mm +++ b/h2mm @@ -1,5 +1,7 @@ #!/bin/bash +VERSION="0.1.6" + # --- Globals --- RED='\033[0;31m' @@ -11,6 +13,10 @@ H2PATH="${HOME}/.config/h2mm/h2path" MODS_DIR="" DB_FILE="" +LAST_UPDATE_FILE="${HOME}/.config/h2mm/last_update" +VERSION_URL="https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/dev/version" +REPO_URL="https://github.com/v4n00/h2mm-cli" + # --- Utility Functions --- function get_filename_without_path() { @@ -82,7 +88,7 @@ function initialize_directories() { # --- Help Functions --- function display_help() { - echo "Helldivers 2 Mod Manager v0.1.6" + echo "Helldivers 2 Mod Manager v${VERSION}" echo "Usage: h2mm [command] [options]" echo "Commands:" echo " install Install a mod with files (short form: h2mm i)." @@ -155,6 +161,35 @@ function display_import_help() { # --- Main Functions --- +# Check for updates + +function check_for_updates() { + if [[ -f "$LAST_UPDATE_FILE" ]]; then + last_update=$(cat "$LAST_UPDATE_FILE") + if [[ $(date +%Y-%m-%d) -gt $(date +%Y-%m-%d -d "$last_update + 7 days") ]]; then + return + fi + else + echo $(date +%Y-%m-%d) > "$LAST_UPDATE_FILE" + exit 0 + fi + + latest_version=$(curl -sS "$VERSION_URL") + if [[ $? -ne 0 ]]; then + echo "${RED}Error:${NC} Could not check for updates." >&2 + return + fi + + if [[ "$latest_version" != "$VERSION" ]]; then + echo -e "${RED}!${NC} A new version of h2mm is available: ${ORANGE}$VERSION${NC} -> ${GREEN}$latest_version${NC}" >&2 + echo -e "${RED}!${NC} You can download it from: $REPO_URL" >&2 + fi + + echo $(date +%Y-%m-%d) > "$LAST_UPDATE_FILE" +} + +# Mod management + function mod_reset() { if [[ "$1" == "--help" || "$1" == "-h" ]]; then display_reset_help @@ -507,6 +542,7 @@ function main() { command="$1" shift initialize_directories + check_for_updates case "$command" in install|i) diff --git a/version b/version new file mode 100644 index 0000000..341cf11 --- /dev/null +++ b/version @@ -0,0 +1 @@ +0.2.0 \ No newline at end of file