Add pass flushing for move money

This commit is contained in:
piv
2023-03-08 10:35:47 +10:30
parent 4c2b9f6915
commit d9f994195e
5 changed files with 128 additions and 32 deletions

View File

@@ -24,11 +24,17 @@ enum Commands {
#[arg(short = 'l', long, value_name = "FILE")]
lines: PathBuf,
#[arg(short = 'a', long, value_name = "FILE")]
accounts: PathBuf,
#[arg(short, long, value_name = "FILE")]
output: Option<PathBuf>,
#[arg(short, long)]
use_numeric_accounts: bool,
#[arg(short, long)]
flush_pass: bool,
},
/// Combines rules to the minimum set required
smush_rules {
@@ -73,9 +79,18 @@ fn main() -> anyhow::Result<()> {
Commands::move_money {
rules,
lines,
accounts,
output,
use_numeric_accounts,
} => move_money(rules, lines, output, use_numeric_accounts),
flush_pass,
} => move_money(
rules,
lines,
accounts,
output,
use_numeric_accounts,
flush_pass,
),
Commands::smush_rules { rules, output } => smush_rules(rules, output),
Commands::allocate_overheads {
lines,
@@ -102,14 +117,18 @@ fn main() -> anyhow::Result<()> {
fn move_money(
rules: PathBuf,
lines: PathBuf,
accounts: PathBuf,
output: Option<PathBuf>,
use_numeric_accounts: bool,
flush_pass: bool,
) -> anyhow::Result<()> {
coster_rs::move_money(
csv::Reader::from_path(rules)?,
csv::Reader::from_path(lines)?,
csv::Reader::from_path(accounts)?,
&mut csv::Writer::from_path(output.unwrap_or(PathBuf::from("output.csv")))?,
use_numeric_accounts,
flush_pass,
)
}