1
Fork 0

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

master
vonavi 2013-09-23 13:31:09 +03:00
parent ffb62df90b
commit 9fde9517f6
1 changed files with 16 additions and 6 deletions

View File

@ -1,22 +1,27 @@
#!/usr/bin/env bash #!/usr/bin/env bash
mynick=iVS myname=iVS
repo=fat0troll/lorchess repo=fat0troll/lorchess
tournament=autumn2013 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 # Note that we use `"$@"' to let each command-line parameter expand to a
# separate word. The quotes around `$@' are essential! # separate word. The quotes around `$@' are essential!
# We need ARGS as the `eval set --' would nuke the return value of getopt. # 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! # Note the quotes around `$ARGS': they are essential!
eval set -- "$args" eval set -- "$args"
if [[ $1 == -n ]] || [[ $1 == --nick ]]; then if [[ $1 == -p ]] || [[ $1 == --player ]]; then
name=$2 name=$2
shift 3 shift 3
else else
name=$mynick name=$myname
shift shift
fi fi
@ -26,6 +31,11 @@ for tour in $@; do
tour=${tour:(-2)} tour=${tour:(-2)}
url=https://raw.github.com/$repo/master/$tournament/tour_$tour/tour_info 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 done