aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2010-06-16 19:30:42 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2010-06-16 19:30:42 +0000
commit716f7b11c380cb07434fd86bf5728574e9d54073 (patch)
tree15c156e1621e0be5e69a40ac3bbdb8c4f086b71f /countify
parentCopy in all of the elections stuff. (diff)
downloadelections-716f7b11c380cb07434fd86bf5728574e9d54073.tar.gz
elections-716f7b11c380cb07434fd86bf5728574e9d54073.tar.bz2
elections-716f7b11c380cb07434fd86bf5728574e9d54073.zip
Show open elections in countify.
Diffstat (limited to 'countify')
-rwxr-xr-xcountify22
1 files changed, 21 insertions, 1 deletions
diff --git a/countify b/countify
index e089584..c882fc7 100755
--- a/countify
+++ b/countify
@@ -23,6 +23,26 @@ use strict;
(my $zero = $0) =~ s,.*/,,;
(my $version = '$Revision: 1.3 $') =~ s/.*?(\d.*\d).*/$zero version $1\n/;
my %opt;
+
+# Collect the open elections
+my (@open_elections, $usage_elections);
+opendir(D, "$Votify::datadir/") or die;
+@open_elections = sort grep {
+ s/^start-// and do {
+ my ($starttime) = (stat _)[9] if stat("$Votify::datadir/start-$_");
+ my ($stoptime) = (stat _)[9] if stat("$Votify::datadir/stop-$_");
+ ((not defined $starttime or $starttime < time) and
+ (not defined $stoptime or $stoptime > time))
+ }
+} readdir D;
+closedir D;
+if (@open_elections) {
+ $usage_elections = join("\n ", @open_elections);
+} else {
+ $usage_elections = "(no elections currently open)";
+}
+
+# rest of usage
my $usage = <<EOT;
usage: $zero <command> <election>
@@ -37,7 +57,7 @@ where <command> is one of:
and <election> is one of the elections currently in-progress. The following
elections are currently open:
- trustees2005
+ $usage_elections
EOT