Upgrade to clap v4, add numeric accounts argument to allocate overheads cli
This commit is contained in:
40
src/main.rs
40
src/main.rs
@@ -5,10 +5,10 @@ use coster_rs::CsvCost;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "coster-rs")]
|
||||
#[clap(author = "Pivato M. <mpivato4@gmail.com>")]
|
||||
#[clap(version = "0.0.1")]
|
||||
#[clap(about = "Simple, fast, efficient costing tool", long_about = None)]
|
||||
#[command(name = "coster-rs")]
|
||||
#[command(author = "Pivato M. <mpivato4@gmail.com>")]
|
||||
#[command(version = "0.0.1")]
|
||||
#[command(about = "Simple, fast, efficient costing tool", long_about = None)]
|
||||
struct Cli {
|
||||
#[clap(subcommand)]
|
||||
command: Commands,
|
||||
@@ -18,44 +18,47 @@ struct Cli {
|
||||
enum Commands {
|
||||
/// Moves money between accounts and departments, using the given rules and lines
|
||||
move_money {
|
||||
#[clap(short = 'r', long, parse(from_os_str), value_name = "FILE")]
|
||||
#[arg(short = 'r', long, value_name = "FILE")]
|
||||
rules: PathBuf,
|
||||
|
||||
#[clap(short = 'l', long, parse(from_os_str), value_name = "FILE")]
|
||||
#[arg(short = 'l', long, value_name = "FILE")]
|
||||
lines: PathBuf,
|
||||
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
output: Option<PathBuf>,
|
||||
|
||||
#[clap(short, long, default_value_t = false)]
|
||||
#[arg(short, long)]
|
||||
use_numeric_accounts: bool,
|
||||
},
|
||||
/// Combines rules to the minimum set required
|
||||
smush_rules {
|
||||
#[clap(short = 'r', long, parse(from_os_str), value_name = "FILE")]
|
||||
#[arg(short = 'r', long, value_name = "FILE")]
|
||||
rules: PathBuf,
|
||||
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
output: Option<PathBuf>,
|
||||
},
|
||||
/// Allocates servicing department amounts to operating departments
|
||||
allocate_overheads {
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
lines: PathBuf,
|
||||
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
accounts: PathBuf,
|
||||
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
#[arg(short = 's', long, value_name = "FILE")]
|
||||
allocation_statistics: PathBuf,
|
||||
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
areas: PathBuf,
|
||||
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
cost_centres: PathBuf,
|
||||
|
||||
#[clap(short, long, parse(from_os_str), value_name = "FILE")]
|
||||
#[arg(short, long)]
|
||||
use_numeric_accounts: bool,
|
||||
|
||||
#[arg(short, long, value_name = "FILE")]
|
||||
output: Option<PathBuf>,
|
||||
},
|
||||
}
|
||||
@@ -77,6 +80,7 @@ fn main() -> anyhow::Result<()> {
|
||||
allocation_statistics,
|
||||
areas,
|
||||
cost_centres,
|
||||
use_numeric_accounts,
|
||||
output,
|
||||
} => allocate_overheads(
|
||||
lines,
|
||||
@@ -84,6 +88,7 @@ fn main() -> anyhow::Result<()> {
|
||||
allocation_statistics,
|
||||
areas,
|
||||
cost_centres,
|
||||
use_numeric_accounts,
|
||||
output,
|
||||
),
|
||||
}
|
||||
@@ -113,6 +118,7 @@ fn allocate_overheads(
|
||||
allocation_statistics: PathBuf,
|
||||
areas: PathBuf,
|
||||
cost_centres: PathBuf,
|
||||
use_numeric_accounts: bool,
|
||||
output: Option<PathBuf>,
|
||||
) -> anyhow::Result<()> {
|
||||
coster_rs::reciprocal_allocation(
|
||||
@@ -122,7 +128,7 @@ fn allocate_overheads(
|
||||
csv::Reader::from_path(areas)?,
|
||||
csv::Reader::from_path(cost_centres)?,
|
||||
&mut csv::Writer::from_path(output.unwrap_or(PathBuf::from("alloc_output.csv")))?,
|
||||
true,
|
||||
use_numeric_accounts,
|
||||
false,
|
||||
true,
|
||||
"E".to_owned(),
|
||||
|
||||
Reference in New Issue
Block a user