lorchess/schedule.sh
2013-09-23 15:04:10 +03:00

46 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
myname=iVS
repo=fat0troll/lorchess
tournament=autumn2013
# Variables
score='\(0\|1\|0\.5\):\(0\|1\|0\.5\)'
# Colors
green='\\033[01;32m'
red='\\033[01;31m'
restore='\\033[00m'
# Note that we use `"$@"' to let each command-line parameter expand to a
# separate word. The quotes around `$@' are essential!
# We need ARGS as the `eval set --' would nuke the return value of getopt.
args=$(getopt --options p: --longoptions player: -- "$@")
# Note the quotes around `$ARGS': they are essential!
eval set -- "$args"
if [[ $1 == -p ]] || [[ $1 == --player ]]; then
name=$2
shift 3
else
name=$myname
shift
fi
for tour in $@; do
# Change tour numbers: `1' -> `01', `2' -> `02', and so on
tour=0"$tour"
tour=${tour:(-2)}
url=https://raw.github.com/$repo/master/$tournament/tour_$tour/tour_info
echo ">>>"
curl -q --silent $url | egrep "Тур|Время|$name" | while read line;do
# Colorize output
line=$(echo $line | sed "s/${score}/${green}\0${restore}/g")
line=$(echo $line | sed "s/${name}/${red}\0${restore}/g")
echo -e $line
done
done