From 28122ee332d37e9ce30a4269c1b62d447919f4d2 Mon Sep 17 00:00:00 2001 From: v4n <105587619+v4n00@users.noreply.github.com> Date: Wed, 5 Mar 2025 19:09:57 +0200 Subject: [PATCH] feat: list is now compact, added verbose option --- h2mm | 50 ++++++++++++++++++++++++++++++++++++++++---------- install.sh | 2 +- version | 2 +- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/h2mm b/h2mm index 72a875c..a44933d 100755 --- a/h2mm +++ b/h2mm @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERSION="0.3.9" +VERSION="0.3.10" # --- Globals --- @@ -233,6 +233,8 @@ function display_disable_help() { function display_list_help() { echo "Usage: h2mm list" echo "Short form: h2mm l" + echo "Options:" + echo " -v Verbose mode." echo "List all installed mods." echo "Database of mods is stored in Steam/steamapps/common/Helldivers\ 2/data/mods.csv" echo "You can rename, delete, or edit this file to manage mods manually." @@ -813,16 +815,39 @@ function mod_uninstall() { } function mod_list() { - [[ "$1" == "--help" || "$1" == "-h" ]] && { display_list_help; exit 0; } + local verbose=false - [[ $(wc -l < "$DB_FILE") -le 1 ]] && { echo "No mods installed."; return; } + # parse arguments + while [[ $# -gt 0 ]]; do + case "$1" in + --help|-h) + display_list_help + exit 0 + ;; + --verbose|-v) + verbose=true + shift + ;; + *) + shift + ;; + esac + done - echo "Installed mods:" >&2 + [[ $(wc -l < "$DB_FILE") -le 1 ]] && { echo "No mods installed."; return; } - awk -v GREEN="$GREEN" -v RED="$RED" -v NC="$NC" -F, 'NR > 1 { - color = ($2 == "DISABLED") ? RED : GREEN; - 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" + echo "Installed mods:" >&2 + + awk -v GREEN="$GREEN" -v RED="$RED" -v NC="$NC" -v verbose="$verbose" -F, 'NR > 1 { + color = ($2 == "DISABLED") ? RED : GREEN; + if (verbose == "false") { + $4 = ""; + } else { + gsub(/ /,"\n -> ", $4); + $4 = "\n -> " $4; + } + printf "%2s. [%s%s%s] %s %s\n", $1, color, $2, NC, $3, $4 + }' "$DB_FILE" } function mod_export() { @@ -1078,7 +1103,7 @@ function self_update() { echo -e "Starting update script..." >&2 - # Run the installer for the latest version + # run the installer for the latest version bash -c "$(curl -fsSL https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/install.sh)" exit 0 } @@ -1091,7 +1116,6 @@ function main() { command="$1" shift initialize_directories - initialize_modpack_directories check_for_updates case "$command" in @@ -1117,21 +1141,27 @@ function main() { mod_import "$@" ;; "modpack-list"|"ml") + initialize_modpack_directories modpack_list "$@" ;; "modpack-create"|"mc") + initialize_modpack_directories modpack_create "$@" ;; "modpack-delete"|"md") + initialize_modpack_directories modpack_delete "$@" ;; "modpack-overwrite"|"mo") + initialize_modpack_directories modpack_overwrite "$@" ;; "modpack-switch"|"ms") + initialize_modpack_directories modpack_switch "$@" ;; "modpack-reset"|"mr") + initialize_modpack_directories modpack_reset "$@" ;; "reset"|"r") diff --git a/install.sh b/install.sh index 5bbe15f..651c8eb 100755 --- a/install.sh +++ b/install.sh @@ -130,4 +130,4 @@ sudo curl "$REPO_URL"/h2mm --output "$DESTINATION_PATH/$SCRIPT_NAME" sudo chmod +x "$DESTINATION_PATH/$SCRIPT_NAME" [[ ! -x "$(command -v $SCRIPT_NAME)" ]] && { echo -e "${RED}Error:${NC} Installation failed. Mod manager was not found in \$PATH." >&2; exit 1; } -echo "Helldivers 2 Mod Manager CLI installed successfully to $DESTINATION_PATH/$SCRIPT_NAME. Use it by running '$SCRIPT_NAME'." >&2 +echo "Helldivers 2 Mod Manager CLI installed successfully to $DESTINATION_PATH/$SCRIPT_NAME. Use it by running '$SCRIPT_NAME'. Made with love <3." >&2 diff --git a/version b/version index 940ac09..5503126 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.3.9 +0.3.10