view nun/tasks/findundone.sh @ 227:c88f0ebda59a misc

Improve findundone script.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 23 Dec 2011 02:26:51 +0200
parents 92cbb05f66a6
children
line wrap: on
line source

#!/bin/sh
TASKDATA="taskdata.txt"
FINDREQS="findreqs.pl"

if test "x$1" = "x"; then
	echo "Find and compute list of undone nun tasks"
	echo "Usage: $0 <logfile>"
	echo ""
	echo "Logfile's last 500 lines MUST contain output of 'list' command"
	echo "from the nun guild task room (at Sister Evelyn)."
	echo "Also requires $TASKDATA and $FINDREQS script."
	exit 0
fi


TMPFILE=`mktemp -t findundone-$USER.XXXXXXXXXX` || exit 1
LOGFILE="$1"

echo "Searching logfile '$LOGFILE' for finished tasks ... "
tail -500 "$LOGFILE" | perl -e 'my @tmp; while (<STDIN>) { if(/^  \| ([A-Z][^|]+)\| \[ \:. \]/) { $s = $1; $s =~ s/ *$//; push(@tmp,$s); }} print "$_\n" foreach (sort { $a cmp $b} @tmp); print STDERR "Found ".(scalar @tmp)." tasks.\n";' > "$TMPFILE"

echo "Checking for missing (unopened) tasks ..."
perl -w "$FINDREQS" -tasks < "$TASKDATA" | while read i; do
	if ! grep "^$i" "$TMPFILE" > /dev/null; then
		echo "* $i"
	fi
done

rm -f "$TMPFILE"