Implement --omit-informal for `opentally convert`

This commit is contained in:
RunasSudo 2021-10-17 16:32:35 +11:00
parent 3ceaf67091
commit 46654f8c5a
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 10 additions and 1 deletions

View File

@ -56,9 +56,13 @@ pub struct SubcmdOptions {
#[clap(help_heading=Some("PREFERENCE VALIDATION"), long)]
require_sequential: bool,
/// Require strict ordering of preferences
/// Require strict ordering of preferences (disallow equal rankings)
#[clap(help_heading=Some("PREFERENCE VALIDATION"), long)]
require_strict_order: bool,
/// Do not output wholly informal ballots
#[clap(help_heading=Some("PREFERENCE VALIDATION"), long)]
omit_informal: bool,
}
/// Entrypoint for subcommand
@ -126,6 +130,11 @@ pub fn main(mut cmd_opts: SubcmdOptions) -> Result<(), i32> {
}
}
if cmd_opts.omit_informal {
// Remove wholly informal ballots from output
election.ballots.retain(|b| !b.preferences.is_empty());
}
// Write output file
let output = File::create(cmd_opts.outfile).expect("IO Error");