Changeset - 984af6c1b83c
[Not reviewed]
0 1 0
Branko Majic (branko) - 2 years ago 2022-06-18 14:19:33
branko@majic.rs
[factorio_manager.sh] Sort instance info mod output list by title.
1 file changed with 15 insertions and 11 deletions:
0 comments (0 inline, 0 general) First comment
games/factorio_manager.sh
Show inline comments
 
@@ -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"
 
                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 "    ($mod_url)"
 
                    echo
 
                    echo "$mod_description"
 
                echo "${extended_information[$mod_title]}"
 
                echo
 
            fi
 
            fi
 
        done
 
        done < <(IFS=$'\n'; echo "${!extended_information[*]}" | sort)
 
    fi
 
    echo
 

	
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now