1
Fork 0
lorchess/schedule

49 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
repo=fat0troll/lorchess
tournament=autumn2013
2013-09-23 16:04:10 +04:00
# Variables
2013-09-26 00:11:13 +04:00
digit='[[:digit:]]\+'
2013-09-23 16:04:10 +04:00
# Colors
2013-09-24 23:05:56 +04:00
cyan='\\033[01;36m'
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.
2013-09-23 14:34:40 +04:00
args=$(getopt --options p: --longoptions player: -- "$@")
# Note the quotes around `$ARGS': they are essential!
eval set -- "$args"
2013-09-26 00:11:13 +04:00
if [[ $1 == -p || $1 == --player ]]; then
name=$2
shift 2
fi
shift
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 ">>>"
2013-09-30 09:38:17 +04:00
curl -q --silent -w '\n' $url | while read line; do
2013-09-26 00:11:13 +04:00
if [[ -z $line ]]; then
echo
2013-09-26 00:11:13 +04:00
elif [[ -z $name || $(egrep "Тур|=|Время|$name" <<< "$line") ]]; then
# Colorize output
2013-09-26 00:11:13 +04:00
line=$(sed "s/${digit}/${cyan}\0${restore}/g" <<< "$line")
[[ -n $name ]] && line=$(sed "s/${name}/${red}\0${restore}/g" <<< "$line")
echo -e $line
fi
done
done
2013-09-26 00:11:13 +04:00
exit 0