From 46654f8c5ae33ddbb994a8e36e41b06d3a31f032 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sun, 17 Oct 2021 16:32:35 +1100 Subject: [PATCH] Implement --omit-informal for `opentally convert` --- src/cli/convert.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cli/convert.rs b/src/cli/convert.rs index 64974ad..17901f0 100644 --- a/src/cli/convert.rs +++ b/src/cli/convert.rs @@ -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");