Changeset - ef192b082541
[Not reviewed]
0 1 0
Branko Majic (branko) - 2 years ago 2022-06-01 22:35:51
branko@majic.rs
Noticket: [factorio_manager.sh] Add verbose output for info command:

- Lists mod URLs and their descriptions.
1 file changed with 30 insertions and 2 deletions:
0 comments (0 inline, 0 general) First comment
games/factorio_manager.sh
Show inline comments
 
@@ -145,6 +145,9 @@ info INSTANCE
 
        - list of enabled/disabled mods
 
        - list of backups
 

	
 
    If verbose mode is enabled, mods are listed with URLs and
 
    description as well.
 

	
 
install GAME_ARCHIVE
 

	
 
    Installs Factorio from the provided archive into the game
 
@@ -214,6 +217,8 @@ $program accepts the following options:
 

	
 
    -C
 
        Force colour output.
 
    -V
 
        Verbose mode. Some commands may provide more output when enabled.
 
    -q
 
        Quiet mode. Output a message only if newer packages are available.
 
    -d
 
@@ -1225,6 +1230,7 @@ ERROR_GENERAL=3
 
# Disable debug and quiet modes by default.
 
debug=0
 
quiet=0
 
verbose=0
 
force_colours=0
 

	
 
# Set-up some default paths.
 
@@ -1239,8 +1245,9 @@ if [[ -z ${1-} ]]; then
 
fi
 

	
 
# Parse the arguments
 
while getopts "Cqdvh" opt; do
 
while getopts "VCqdvh" opt; do
 
    case "$opt" in
 
        V) verbose=1;;
 
        C) force_colours=1;;
 
	q) # shellcheck disable=SC2034 # part of standard Bash script template.
 
           quiet=1;;
 
@@ -1901,7 +1908,7 @@ elif [[ $command == info ]]; then
 
        echo "Available mods: none"
 

	
 
    # Listing using just regular tools.
 
    elif ! hash jqs 2>/dev/null; then
 
    elif ! hash jq 2>/dev/null; then
 
        echo "Available mods:"
 
        echo
 

	
 
@@ -1936,6 +1943,17 @@ elif [[ $command == info ]]; then
 

	
 
                # Show colored-information for the mod.
 
                printf "$color  - %-48s %8s $_text_reset\n" "$mod_name" "$mod_version"
 
                if (( verbose == 1 )); then
 
                    mod_info=$(unzip -Z1 "$mod_file" | grep "info\.json" | head -n1)
 
                    mod_description=$(unzip -p "$mod_file" "$mod_info" | grep '"description":' | sed -e 's/\r//g;s/[^"]*"description": //;s/^"//;s/"$//')
 
                    mod_description=$(echo -e "$mod_description" | fold -s -w 50 | sed -e 's/^/    /')
 
                    mod_url="https://mods.factorio.com/mod/${mod_info}"
 
                    echo
 
                    echo "    ($mod_url)"
 
                    echo
 
                    echo "$mod_description"
 
                    echo
 
                fi
 
            fi
 

	
 
        done
 
@@ -1983,6 +2001,16 @@ elif [[ $command == info ]]; then
 

	
 
                # Show colored-information for the mod.
 
                printf "$color  - %-48s %8s $_text_reset\n" "$mod_name" "$mod_version"
 
                if (( verbose == 1 )); then
 
                    mod_info=$(unzip -Z1 "$mod_file" | grep "info\.json" | head -n1)
 
                    mod_description=$(unzip -p "$mod_file" "$mod_info" | jq -r -e '.description' | fold -s -w 50 | sed -e 's/^/    /')
 
                    mod_url="https://mods.factorio.com/mod/${mod_info}"
 
                    echo
 
                    echo "    ($mod_url)"
 
                    echo
 
                    echo "$mod_description"
 
                    echo
 
                fi
 
            fi
 
        done
 
    fi
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now