2013-09-21 03:20:19 +04:00
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
2013-09-23 14:31:09 +04:00
|
|
|
|
myname=iVS
|
2013-09-21 03:20:19 +04:00
|
|
|
|
repo=fat0troll/lorchess
|
|
|
|
|
tournament=autumn2013
|
|
|
|
|
|
2013-09-23 14:31:09 +04:00
|
|
|
|
# Colors
|
|
|
|
|
green='\\033[01;32m'
|
|
|
|
|
red='\\033[01;31m'
|
|
|
|
|
restore='\\033[00m'
|
|
|
|
|
|
2013-09-21 03:20:19 +04:00
|
|
|
|
# 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.
|
2013-09-23 14:31:09 +04:00
|
|
|
|
args=`getopt --options p: --longoptions player: -- "$@"`
|
2013-09-21 03:20:19 +04:00
|
|
|
|
|
|
|
|
|
# Note the quotes around `$ARGS': they are essential!
|
|
|
|
|
eval set -- "$args"
|
|
|
|
|
|
2013-09-23 14:31:09 +04:00
|
|
|
|
if [[ $1 == -p ]] || [[ $1 == --player ]]; then
|
2013-09-21 03:20:19 +04:00
|
|
|
|
name=$2
|
|
|
|
|
shift 3
|
|
|
|
|
else
|
2013-09-23 14:31:09 +04:00
|
|
|
|
name=$myname
|
2013-09-21 03:20:19 +04:00
|
|
|
|
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
|
2013-09-23 14:31:09 +04:00
|
|
|
|
|
|
|
|
|
echo ">>>"
|
|
|
|
|
curl -q --silent $url | egrep "Тур|Время|$name" | while read line;do
|
|
|
|
|
# Colorize the player name
|
|
|
|
|
output=$(echo $line | sed "s/${name}/${red}${name}${restore}/g")
|
|
|
|
|
echo -e $output
|
|
|
|
|
done
|
2013-09-21 03:20:19 +04:00
|
|
|
|
done
|