Change 'nick' option to 'player'. Add colorized output of player name.

This commit is contained in:
vonavi 2013-09-23 13:31:09 +03:00
parent ffb62df90b
commit 9fde9517f6

View File

@ -1,22 +1,27 @@
#!/usr/bin/env bash
mynick=iVS
myname=iVS
repo=fat0troll/lorchess
tournament=autumn2013
# 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 n: --longoptions nick: -- "$@"`
args=`getopt --options p: --longoptions player: -- "$@"`
# Note the quotes around `$ARGS': they are essential!
eval set -- "$args"
if [[ $1 == -n ]] || [[ $1 == --nick ]]; then
if [[ $1 == -p ]] || [[ $1 == --player ]]; then
name=$2
shift 3
else
name=$mynick
name=$myname
shift
fi
@ -26,6 +31,11 @@ for tour in $@; do
tour=${tour:(-2)}
url=https://raw.github.com/$repo/master/$tournament/tour_$tour/tour_info
curl -q --silent $url | egrep "Тур|Время|$name"
echo " ***"
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
done