added: use out_runid.csv as default output path

This commit is contained in:
Wataru Otsubo 2024-07-25 23:34:27 +09:00
parent 1ec3f8107c
commit 772f7a155f
4 changed files with 34 additions and 10 deletions

View file

@ -11,7 +11,7 @@ use anyhow::{anyhow, Context, Result};
use chrono::{DateTime, Utc};
use clap::{Parser, Subcommand};
use log::{debug, error, info, trace, warn};
use masterlog::MasterLogResult;
use masterlog::{get_output_filename, MasterLogResult};
use semver::Version;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};
@ -36,8 +36,9 @@ pub enum Commands {
/// Master log file.
master_log: path::PathBuf,
/// Output CSV file.
/// Default is `out_<runid>.csv`
// #[arg(default_value = get_default_log_path().into_os_string())]
outfile: PathBuf,
outfile: Option<PathBuf>,
},
/// Check CSV format
CheckDB {
@ -377,6 +378,8 @@ fn main() -> Result<()> {
}
}
let outfile = outfile.unwrap_or(get_output_filename(&result));
let expanded_results = PsbQaqcResult::from_masterlogresult(result);
let mut wtr = match outfile.exists() {

View file

@ -1,4 +1,4 @@
use std::{collections::BTreeMap, io::BufRead, str::FromStr};
use std::{collections::BTreeMap, io::BufRead, path::PathBuf, str::FromStr};
use anyhow::{anyhow, Context, Result};
use chrono::{DateTime, Utc};
@ -6,7 +6,7 @@ use log::{debug, info, trace};
use regex::Regex;
use semver::Version;
use crate::{Position, PositionLayer, PsbId};
use crate::{Position, PositionLayer, PsbId, PsbQaqcResult};
/// QAQC results for each boards extracted from master log.
///
@ -303,6 +303,10 @@ impl MasterLogResult {
}
}
pub fn get_output_filename(result: &MasterLogResult) -> PathBuf {
PathBuf::from(format!("out_{}.csv", result.runid))
}
#[cfg(test)]
mod test {
use semver::Version;