From e6515551e0c9b87d2d4b9bb30df6ee462cfd3da5 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Sun, 22 Jul 2018 23:06:44 -0700 Subject: countify: make it hard to count an election that is still open Signed-off-by: Robin H. Johnson --- countify | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/countify b/countify index f151d42..a4e328e 100755 --- a/countify +++ b/countify @@ -53,8 +53,9 @@ where 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 is one of the elections currently in-progress. The following +and 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'}) { -- cgit v1.2.3-65-gdbad