Changeset - 5d8f4266050d
[Not reviewed]
0 1 0
Branko Majic (branko) - 4 years ago 2020-07-05 00:46:49
branko@majic.rs
Noticket: Clean-up set-game-dir command in Factorio Manager:

- Small refactoring and fixing of variable names and outputs.
1 file changed with 9 insertions and 12 deletions:
0 comments (0 inline, 0 general) First comment
games/factorio_manager.sh
Show inline comments
 
@@ -872,49 +872,46 @@ shift
 
#==============#
 
# set-game-dir #
 
#==============#
 
if [[ $command == set-game-dir ]]; then
 

	
 
    # Read and verify additional positional arguments.
 
    game_installations_directory="${1-}"
 
    game_installations_directory_target="${1-}"
 
    shift
 

	
 
    if [[ -z $game_installations_directory ]]; then
 
    if [[ -z $game_installations_directory_target ]]; then
 
        error "Missing argument: GAME_INSTALLATIONS_DIRECTORY"
 
        exit "$ERROR_ARGUMENTS"
 
    fi
 

	
 
    if [[ ! -e $game_installations_directory ]]; then
 
    if [[ ! -e $game_installations_directory_target ]]; then
 
        error "No such directory: $game_installations_directory"
 
        exit "$ERROR_GENERAL"
 
    fi
 

	
 
    # Set-up additional derived variables.
 
    symlink="$manager_directory/.game_installations"
 

	
 
    # Verify that at least one Factorio instance can be found.
 
    factorio_versions_found=0
 
    for candidate in "$game_installations_directory"/*; do
 
    for candidate in "$game_installations_directory_target"/*; do
 
        if [[ -f $candidate/bin/x64/factorio ]]; then
 
            let factorio_versions_found++
 
        fi
 
    done
 

	
 
    if (( $factorio_versions_found == 0 )); then
 
        error "Could not locate any Factorio installations under: $game_installations_directory"
 
        error "Could not locate any Factorio installations under: $game_installations_directory_target"
 

	
 
        exit "$ERROR_GENERAL"
 
    fi
 

	
 
    # Update the link
 
    if [[ -L $symlink ]]; then
 
        rm "$symlink"
 
    if [[ -L $game_installations_directory ]]; then
 
        rm "$game_installations_directory"
 
    fi
 

	
 
    if ! ln -s "$game_installations_directory" "$symlink"; then
 
        error "Could not create symlink from $game_installations_directory to $symlink."
 
    if ! ln -s "$game_installations_directory_target" "$game_installations_directory"; then
 
        error "Could not create symlink from '$game_installations_directory_target' to '$game_installations_directory'."
 

	
 
        exit "$ERROR_GENERAL"
 
    fi
 

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