diff --git a/games/factorio_manager.sh b/games/factorio_manager.sh index 415ec7fcf764d50a98768a37838107866caf5ff7..159a630d66d2eba515da939da5cc3870c68204b9 100755 --- a/games/factorio_manager.sh +++ b/games/factorio_manager.sh @@ -1941,16 +1941,15 @@ elif [[ $command == info ]]; then # shellcheck disable=SC2016 # The $enable_new_mods is meant to be interpreted by jq, not bash. jq_is_enabled_query='.mods | map(select(.name==$mod_name))[0] // {"name": "default", "enabled": $enable_new_mods} | .enabled' + # Store information for sorting by title. + declare -A basic_information + declare -A extended_information + # Process every mod found. for mod_file in "${mod_files[@]}"; do if [[ -f $mod_file ]]; then - # Extract internal name of the mod (used for URL paths - # etc). Differs from data stored in info.json. - mod_basename=$(basename "$mod_file" .zip) - mod_internal_name="${mod_basename%_*}" - # Extract mod information. mod_info_file=$(unzip -Z1 "$mod_file" | grep "info\.json" | head -n1) mod_info=$(unzip -p "$mod_file" "$mod_info_file") @@ -1974,16 +1973,21 @@ elif [[ $command == info ]]; then fi # Show colored-information for the mod. - printf "$color - %-48s %8s $_text_reset\n" "$mod_title" "$mod_version" - if (( verbose == 1 )); then - echo - echo " ($mod_url)" - echo - echo "$mod_description" - echo - fi + basic_information[$mod_title]=$(printf "$color - %-48s %8s $_text_reset\n" "$mod_title" "$mod_version") + extended_information[$mod_title]=$(printf " (%s)\n\n%s" "$mod_url" "$mod_description") fi done + + # Output information, sorted by title. + while read -r mod_title; do + echo "${basic_information[$mod_title]}" + + if (( verbose == 1 )); then + echo + echo "${extended_information[$mod_title]}" + echo + fi + done < <(IFS=$'\n'; echo "${!extended_information[*]}" | sort) fi echo