diff --git a/game-add b/game-add index c53a86a..357628d 100755 --- a/game-add +++ b/game-add @@ -197,12 +197,14 @@ function game_validate { fi # Players' sides should interchange + local length=$(echo -en "$ply_names" | wc -l) if $ADD_GAMES && [[ -n $res_old ]]; then local residue=$(( $(wc -w <<< "$res_old") % 2 )) else local residue=0 fi + local ply_ordered= for ((i = 0; i < length; i++)); do if (( i % 2 == residue )); then @@ -211,7 +213,16 @@ function game_validate { ply_ordered+="${black}\n" fi done + + # List found games + echo "$(tput setaf 2)Found games:$(tput sgr0)" + game_display "$ply_names" + if [[ "$ply_names" != "$ply_ordered" ]]; then + # List expected games + echo "$(tput setaf 2)Expected games:$(tput sgr0)" + game_display "$ply_ordered" + local answer echo -n "Approve games with wrong players' sides? (Y/n)> " read answer @@ -219,6 +230,11 @@ function game_validate { fi } +function game_display { + echo -e "$1" | xargs -n2 \ + | sed "s/ / - /;s/^/$(tput setaf 6)*$(tput sgr0) /" +} + function game_store_pgns { game_dir=$(ls -1 -d 2>/dev/null \ ${REPO_DIR}/${TOURNAMENT}/tours/${TOUR}/*-${white}-vs-${black})