Add optional messagepack output for overhead allocation to cli
This commit is contained in:
58
src/main.rs
58
src/main.rs
@@ -1,4 +1,4 @@
|
|||||||
use std::path::PathBuf;
|
use std::{fs::File, io::BufWriter, path::PathBuf};
|
||||||
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
@@ -69,8 +69,11 @@ enum Commands {
|
|||||||
#[arg(short, long, default_value = "0.00000000000000001")]
|
#[arg(short, long, default_value = "0.00000000000000001")]
|
||||||
zero_threshold: f64,
|
zero_threshold: f64,
|
||||||
|
|
||||||
#[arg(short, long, value_name = "FILE")]
|
#[arg(short, long, value_name = "FILE", default_value = "alloc_output.csv")]
|
||||||
output: Option<PathBuf>,
|
output: PathBuf,
|
||||||
|
|
||||||
|
#[arg(short, long)]
|
||||||
|
msgpack_serialisation: bool,
|
||||||
},
|
},
|
||||||
CreateProducts {
|
CreateProducts {
|
||||||
#[arg(short, long, value_name = "FILE")]
|
#[arg(short, long, value_name = "FILE")]
|
||||||
@@ -129,20 +132,41 @@ fn main() -> anyhow::Result<()> {
|
|||||||
show_from,
|
show_from,
|
||||||
zero_threshold,
|
zero_threshold,
|
||||||
output,
|
output,
|
||||||
} => coster_rs::reciprocal_allocation(
|
msgpack_serialisation,
|
||||||
&mut csv::Reader::from_path(lines)?,
|
} => {
|
||||||
&mut csv::Reader::from_path(accounts)?,
|
if msgpack_serialisation {
|
||||||
&mut csv::Reader::from_path(allocation_statistics)?,
|
let mut file = BufWriter::new(File::create(output)?);
|
||||||
&mut csv::Reader::from_path(areas)?,
|
coster_rs::reciprocal_allocation(
|
||||||
&mut csv::Reader::from_path(cost_centres)?,
|
&mut csv::Reader::from_path(lines)?,
|
||||||
&mut csv::Writer::from_path(output.unwrap_or(PathBuf::from("alloc_output.csv")))?,
|
&mut csv::Reader::from_path(accounts)?,
|
||||||
use_numeric_accounts,
|
&mut csv::Reader::from_path(allocation_statistics)?,
|
||||||
exclude_negative_allocation_statistics,
|
&mut csv::Reader::from_path(areas)?,
|
||||||
true,
|
&mut csv::Reader::from_path(cost_centres)?,
|
||||||
account_type,
|
&mut rmp_serde::Serializer::new(&mut file),
|
||||||
show_from,
|
use_numeric_accounts,
|
||||||
zero_threshold,
|
exclude_negative_allocation_statistics,
|
||||||
),
|
true,
|
||||||
|
account_type,
|
||||||
|
show_from,
|
||||||
|
zero_threshold,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
coster_rs::reciprocal_allocation(
|
||||||
|
&mut csv::Reader::from_path(lines)?,
|
||||||
|
&mut csv::Reader::from_path(accounts)?,
|
||||||
|
&mut csv::Reader::from_path(allocation_statistics)?,
|
||||||
|
&mut csv::Reader::from_path(areas)?,
|
||||||
|
&mut csv::Reader::from_path(cost_centres)?,
|
||||||
|
&mut csv::Writer::from_path(output)?,
|
||||||
|
use_numeric_accounts,
|
||||||
|
exclude_negative_allocation_statistics,
|
||||||
|
true,
|
||||||
|
account_type,
|
||||||
|
show_from,
|
||||||
|
zero_threshold,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Commands::CreateProducts {
|
Commands::CreateProducts {
|
||||||
definitions,
|
definitions,
|
||||||
encounters,
|
encounters,
|
||||||
|
|||||||
@@ -780,7 +780,6 @@ impl<W: Write> RecordSerializer for Serializer<W> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::fs::File;
|
|
||||||
|
|
||||||
use crate::reciprocal_allocation;
|
use crate::reciprocal_allocation;
|
||||||
use crate::AccountCost;
|
use crate::AccountCost;
|
||||||
@@ -789,7 +788,6 @@ mod tests {
|
|||||||
use crate::TotalDepartmentCost;
|
use crate::TotalDepartmentCost;
|
||||||
|
|
||||||
use super::reciprocal_allocation_impl;
|
use super::reciprocal_allocation_impl;
|
||||||
use super::MovedAmount;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_basic() {
|
fn test_basic() {
|
||||||
|
|||||||
Reference in New Issue
Block a user