fix: docs for help, backup before upgrading script

This commit is contained in:
v4n
2025-01-16 17:08:34 +02:00
parent 7b25b235fa
commit 740b0edd98
3 changed files with 21 additions and 14 deletions
+13 -11
View File
@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
VERSION="0.2.0" VERSION="0.2.1"
# --- Globals --- # --- Globals ---
@@ -115,17 +115,19 @@ function display_help() {
echo "Helldivers 2 Mod Manager v${VERSION}" echo "Helldivers 2 Mod Manager v${VERSION}"
echo "Usage: h2mm [command] [options]" echo "Usage: h2mm [command] [options]"
echo "Commands:" echo "Commands:"
echo " install Install a mod with files (short form: h2mm i)." echo " install Install a mod with files."
echo " uninstall Uninstall a mod by name (short form: h2mm u)." echo " uninstall Uninstall a mod by name."
echo " list List all installed mods (short form: h2mm l)." echo " list List all installed mods."
echo " export <zip_name> Export installed mods to a zip file (short form: h2mm ex)." echo " enable Enable a mod by name."
echo " import <zip_name> Import mods from a zip file (short form: h2mm im)." echo " disable Disable a mod by name."
echo " reset Reset all installed mods (short form: h2mm rr)." echo " export <zip_name> Export installed mods to a zip file."
echo " help Display this help message (short form: h2mm h)." echo " import <zip_name> Import mods from a zip file."
echo " reset Reset all installed mods."
echo " help Display this help message."
echo "For more information on usage, use h2mm [command] --help, available for install and uninstall." echo "For more information on usage, use h2mm [command] --help, available for install and uninstall."
echo "Basic Usage:" echo "Basic Usage:"
echo " h2mm install -z /path/to/mod.zip" echo " h2mm install /path/to/mod.zip"
echo " h2mm install -d /path/to/mod/files" echo " h2mm install /path/to/mod/files"
echo " h2mm uninstall \"Example mod\"" echo " h2mm uninstall \"Example mod\""
} }
@@ -568,7 +570,7 @@ function mod_list() {
echo "Installed mods:" >&2 echo "Installed mods:" >&2
awk -v GREEN="$GREEN" -v RED="$RED" -v NC="$NC" -F, '{ awk -v GREEN="$GREEN" -v RED="$RED" -v NC="$NC" -F, '{
color = ($2 == "DISABLED") ? RED : GREEN; color = ($2 == "DISABLED") ? RED : GREEN;
if (length($3) > 150) $3 = substr($3, 1, 147) "..."; if (length($4) > 150) $4 = substr($4, 1, 147) "...";
printf "%2s. [%s%s%s] %s (%s)\n", $1, color, $2, NC, $3, $4}' "$DB_FILE" printf "%2s. [%s%s%s] %s (%s)\n", $1, color, $2, NC, $3, $4}' "$DB_FILE"
} }
+7 -2
View File
@@ -75,10 +75,14 @@ if [[ -x "$(command -v $SCRIPT_NAME)" ]]; then
fi fi
[[ ! -f "$game_dir/mods.csv" ]] && { echo -e "${RED}Error:${NC} mods.csv not found in $game_dir."; exit 1; } [[ ! -f "$game_dir/mods.csv" ]] && { echo -e "${RED}Error:${NC} mods.csv not found in $game_dir."; exit 1; }
# make backup of mods in case something goes wrong
echo "Creating a backup of mods.csv."
h2mm export
# iterate from installed major number to latest major number # iterate from installed major number to latest major number
for ((i = installed_major + 1; i <= latest_major; i++)); do for ((i = installed_major + 1; i <= latest_major; i++)); do
echo -e "${RED}[ ]${NC} Applying breaking changes patch for version $i." echo -e "Applying breaking changes patch for version $i."
[[ -n "${breaking_changes_patches[$i]}" ]] && eval $(echo "${breaking_changes_patches[$i]}" | sed "s:\$1:$game_dir:") [[ -n "${breaking_changes_patches[$i]}" ]] && eval $(echo "${breaking_changes_patches[$i]}" | sed "s:\$1:$game_dir:")
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
@@ -87,10 +91,11 @@ if [[ -x "$(command -v $SCRIPT_NAME)" ]]; then
[[ "$response" != "y" && "$response" != "Y" && -n "$response" ]] && { echo "Exiting. Uninstall the script first the retry the install script."; exit 1; } [[ "$response" != "y" && "$response" != "Y" && -n "$response" ]] && { echo "Exiting. Uninstall the script first the retry the install script."; exit 1; }
else else
echo -e "${GREEN}[X]${NC} Breaking changes patch for version $i applied successfully." echo -e "Breaking changes patch for version $i applied ${GREEN}successfully${NC}."
fi fi
done done
fi fi
echo
fi fi
# Install # Install
+1 -1
View File
@@ -1 +1 @@
0.2.0 0.2.1