]> mj.ucw.cz Git - moe.git/commitdiff
mop: mo-score has gained a --table option for nice textual tables
authorMartin Mares <mj@ucw.cz>
Sat, 27 Mar 2010 20:15:42 +0000 (21:15 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 27 Mar 2010 20:15:42 +0000 (21:15 +0100)
mop/eval/mo-score.sh

index 9ed73f4a2cb8f144a08d2330dea88553f550ea97..9d0a200ec13f29e72669b848d1bce8ffa5dc2dad 100755 (executable)
@@ -8,7 +8,8 @@ $tex = 0;
 $extras = 0;
 $alt = 0;
 $merged = 0;
-$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] [--merged] [<directory>/]<task> ...";
+$table = 0;
+$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] [--table] [--merged] [<directory>/]<task> ...";
 while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) {
        shift @ARGV;
        $var = "\$$1";
@@ -17,6 +18,12 @@ while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) {
 }
 @ARGV || die $usage;
 
+$print_key = 1;
+if ($table) {
+       open STDOUT, "|column -t -s'\t'" or die;
+       $print_key = 0;
+}
+
 print STDERR "Scanning contestants... ";
 open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants";
 while (<CT>) {
@@ -219,11 +226,12 @@ if ($debug) {
        print "\\error{TeX output not supported yet!}\n";
 } else {
        foreach $r (@table) { print join("\t",@$r), "\n"; }
-       print "\n";
-       foreach $r (sort keys %error_codes) { print "$r: $error_codes{$r}\n"; }
+       if ($print_key) {
+               print "\n";
+               foreach $r (sort keys %error_codes) { print "$r: $error_codes{$r}\n"; }
+       }
 }
 
-
 sub printHtmlRow {
        print "<TR>", join('',map {
                if ($hdr) { $_ = "<TH>$_"; }
@@ -231,7 +239,6 @@ sub printHtmlRow {
        } @_), "\n";
 }
 
-
 sub printHtmlHeader {
 
   my ($perm) = @_;