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};
|
||||
|
||||
@@ -69,8 +69,11 @@ enum Commands {
|
||||
#[arg(short, long, default_value = "0.00000000000000001")]
|
||||
zero_threshold: f64,
|
||||
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
output: Option<PathBuf>,
|
||||
#[arg(short, long, value_name = "FILE", default_value = "alloc_output.csv")]
|
||||
output: PathBuf,
|
||||
|
||||
#[arg(short, long)]
|
||||
msgpack_serialisation: bool,
|
||||
},
|
||||
CreateProducts {
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
@@ -129,20 +132,41 @@ fn main() -> anyhow::Result<()> {
|
||||
show_from,
|
||||
zero_threshold,
|
||||
output,
|
||||
} => 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.unwrap_or(PathBuf::from("alloc_output.csv")))?,
|
||||
use_numeric_accounts,
|
||||
exclude_negative_allocation_statistics,
|
||||
true,
|
||||
account_type,
|
||||
show_from,
|
||||
zero_threshold,
|
||||
),
|
||||
msgpack_serialisation,
|
||||
} => {
|
||||
if msgpack_serialisation {
|
||||
let mut file = BufWriter::new(File::create(output)?);
|
||||
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 rmp_serde::Serializer::new(&mut file),
|
||||
use_numeric_accounts,
|
||||
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 {
|
||||
definitions,
|
||||
encounters,
|
||||
|
||||
Reference in New Issue
Block a user