feat: list is now compact, added verbose option

This commit is contained in:
v4n
2025-03-05 19:09:57 +02:00
parent 56bb73784e
commit 28122ee332
3 changed files with 42 additions and 12 deletions
+40 -10
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
VERSION="0.3.9" VERSION="0.3.10"
# --- Globals --- # --- Globals ---
@@ -233,6 +233,8 @@ function display_disable_help() {
function display_list_help() { function display_list_help() {
echo "Usage: h2mm list" echo "Usage: h2mm list"
echo "Short form: h2mm l" echo "Short form: h2mm l"
echo "Options:"
echo " -v Verbose mode."
echo "List all installed mods." echo "List all installed mods."
echo "Database of mods is stored in Steam/steamapps/common/Helldivers\ 2/data/mods.csv" 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." echo "You can rename, delete, or edit this file to manage mods manually."
@@ -813,16 +815,39 @@ function mod_uninstall() {
} }
function mod_list() { 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 { echo "Installed mods:" >&2
color = ($2 == "DISABLED") ? RED : GREEN;
if (length($4) > 150) $4 = substr($4, 1, 147) "..."; awk -v GREEN="$GREEN" -v RED="$RED" -v NC="$NC" -v verbose="$verbose" -F, 'NR > 1 {
printf "%2s. [%s%s%s] %s (%s)\n", $1, color, $2, NC, $3, $4}' "$DB_FILE" 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() { function mod_export() {
@@ -1078,7 +1103,7 @@ function self_update() {
echo -e "Starting update script..." >&2 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)" bash -c "$(curl -fsSL https://raw.githubusercontent.com/v4n00/h2mm-cli/refs/heads/master/install.sh)"
exit 0 exit 0
} }
@@ -1091,7 +1116,6 @@ function main() {
command="$1" command="$1"
shift shift
initialize_directories initialize_directories
initialize_modpack_directories
check_for_updates check_for_updates
case "$command" in case "$command" in
@@ -1117,21 +1141,27 @@ function main() {
mod_import "$@" mod_import "$@"
;; ;;
"modpack-list"|"ml") "modpack-list"|"ml")
initialize_modpack_directories
modpack_list "$@" modpack_list "$@"
;; ;;
"modpack-create"|"mc") "modpack-create"|"mc")
initialize_modpack_directories
modpack_create "$@" modpack_create "$@"
;; ;;
"modpack-delete"|"md") "modpack-delete"|"md")
initialize_modpack_directories
modpack_delete "$@" modpack_delete "$@"
;; ;;
"modpack-overwrite"|"mo") "modpack-overwrite"|"mo")
initialize_modpack_directories
modpack_overwrite "$@" modpack_overwrite "$@"
;; ;;
"modpack-switch"|"ms") "modpack-switch"|"ms")
initialize_modpack_directories
modpack_switch "$@" modpack_switch "$@"
;; ;;
"modpack-reset"|"mr") "modpack-reset"|"mr")
initialize_modpack_directories
modpack_reset "$@" modpack_reset "$@"
;; ;;
"reset"|"r") "reset"|"r")
+1 -1
View File
@@ -130,4 +130,4 @@ sudo curl "$REPO_URL"/h2mm --output "$DESTINATION_PATH/$SCRIPT_NAME"
sudo chmod +x "$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; } [[ ! -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
+1 -1
View File
@@ -1 +1 @@
0.3.9 0.3.10