aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2018-07-22 23:06:44 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2018-07-22 23:06:44 -0700
commite6515551e0c9b87d2d4b9bb30df6ee462cfd3da5 (patch)
treec000a2641555239e8d03bc45b6b7003b1f61fc21
parentAdd election state tracking (diff)
downloadelections-election-state-verify.tar.gz
elections-election-state-verify.tar.bz2
elections-election-state-verify.zip
countify: make it hard to count an election that is still openelection-state-verify
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rwxr-xr-xcountify10
1 files changed, 8 insertions, 2 deletions
diff --git a/countify b/countify
index f151d42..a4e328e 100755
--- a/countify
+++ b/countify
@@ -53,8 +53,9 @@ where <command> is one of:
--rank Show ranking based on master ballot
--help Show this help message
--version Show version information
+ --force Collect even if the election is not yet closed.
-and <election> is one of the elections currently in-progress. The following
+and <election> is one of the elections currently in-progress or recently closed. The following
elections are currently open:
$usage_elections
@@ -79,13 +80,18 @@ my ($result) = GetOptions(
'rank', # show the ranking based on a master ballot
'help', # help message
'version', # version information
+ 'force', # collect on not-closed election
);
if ($opt{'help'} or not %opt) { print STDERR $usage; exit 0 }
if ($opt{'version'}) { print STDERR $version; exit 0 }
-die "$zero: only one command allowed; use --help for help\n" if 1 < keys %opt;
+die "$zero: only one command allowed; use --help for help\n" if List::Util::sum($opt{'collect'} || 0, $opt{'rank'} || 0, $opt{'help'} || 0, $opt{'version'} || 0) != 1;
die "$zero: election required; use --help for help\n" unless @ARGV == 1;
my ($election) = $ARGV[0];
+my $election_ref = Votify::get_single_election_hashref($election, 0);
+if(%$election_ref{'valid'} && not defined $opt{'force'}) {
+ die "$zero: election $election is still open. Pass --force to count anyway."
+}
my ($vl) = VoterList->new($election);
if ($opt{'collect'}) {