make logging variable via args

This commit is contained in:
Max Känner 2023-07-30 14:44:44 +02:00
parent 898fbb0c4e
commit a98c8470b0

View File

@ -1,6 +1,6 @@
use std::{cmp::Ordering, path::Path};
use std::{cmp::Ordering, path::Path, str::FromStr};
use clap::Parser;
use clap::{ArgAction, Parser};
use color_eyre::eyre::Result;
use icu_locid::locale;
use log::{debug, error, info};
@ -9,11 +9,26 @@ use spreadsheet_ods::{
formula::{fcellref, fcellrefa, fcellrefa_table},
write_ods, Sheet, WorkBook,
};
use stderrlog::Timestamp;
/// Takes multiple csv bom files as input and combines them into one big ods file.
/// Parts will be grouped by value, footprint and WE Part number.
/// The summary is sorted by footprint first, then value.
#[derive(Parser, Debug)]
struct Args {
#[arg(short, long)]
/// Silence all output
quiet: bool,
#[arg(short, long, action = ArgAction::Count)]
/// verbosity
verbose: u8,
#[arg(short, long)]
/// prepend log lines with a timestamp [none, sec, ms, ns]
timestamp: Option<String>,
/// csv bom files exported from KiCad
#[arg(required = true)]
input: Vec<String>,
/// output ods file
output: String,
}
@ -39,11 +54,17 @@ struct Bom {
fn main() -> Result<()> {
color_eyre::install()?;
let args = Args::parse();
stderrlog::new()
.module(module_path!())
.verbosity(2)
.quiet(args.quiet)
.verbosity(args.verbose as usize)
.timestamp(
args.timestamp
.map(|v| Timestamp::from_str(&v).unwrap())
.unwrap_or(Timestamp::Off),
)
.init()?;
let args = Args::parse();
let mut boms = vec![];