Compare commits

..

No commits in common. "main" and "v2.0.0" have entirely different histories.
main ... v2.0.0

4 changed files with 17 additions and 37 deletions

View file

@ -7,17 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed
- `add-master-log` now always create CSV file
- `convert-master-log` can still append to a CSV file
## [2.0.1]
### Fix
- version in Cargo.toml
## [2.0.0] ## [2.0.0]
### Added ### Added
@ -54,9 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Subcommand `add-master-log` to parse master log for shiftwork 0.1.0 and write out to CSV. - Subcommand `add-master-log` to parse master log for shiftwork 0.1.0 and write out to CSV.
- Subcommand `check-db` to validate the database CSV file. - Subcommand `check-db` to validate the database CSV file.
[Unreleased]: https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess/-/compare/v1.0.1...main [Unreleased]: https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess/-/compare/main...v1.0.1
[2.0.1]: https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess/-/compare/v2.0.0...v2.0.1 [2.0.0]: https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess/-/compare/v2.0.0...v1.1.0
[2.0.0]: https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess/-/compare/v1.1.0...v2.0.0 [1.1.0]: https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess/-/compare/v1.1.0...v1.0.1
[1.1.0]: https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess/-/compare/v1.0.1...v1.1.0 [1.0.1]: https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess/-/compare/v1.0.1...v1.0.0
[1.0.1]: https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess/-/compare/v1.0.0...v1.0.1
[1.0.0]: https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess/-/tags/v1.0.0 [1.0.0]: https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess/-/tags/v1.0.0

2
Cargo.lock generated
View file

@ -730,7 +730,7 @@ dependencies = [
[[package]] [[package]]
name = "psb-qaqc" name = "psb-qaqc"
version = "2.0.1" version = "1.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"assert_cmd", "assert_cmd",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "psb-qaqc" name = "psb-qaqc"
version = "2.0.1" version = "1.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View file

@ -4,7 +4,7 @@ use std::{
fmt::Display, fmt::Display,
fs::{self, File}, fs::{self, File},
io::{self, BufRead, BufReader}, io::{self, BufRead, BufReader},
path::{self, PathBuf}, path::{self, Path, PathBuf},
str::FromStr, str::FromStr,
}; };
@ -351,12 +351,11 @@ impl PsbQaqcResult {
// .collect_vec() // .collect_vec()
// } // }
/// If `nonewfile` is `true`, out file is not created when there is already a file. fn write_psbqaqc_csv(result: MasterLogResult, outfile: PathBuf) -> Result<()> {
fn write_psbqaqc_csv(result: MasterLogResult, outfile: PathBuf, nonewfile: bool) -> Result<()> {
let expanded_results = PsbQaqcResult::from_masterlogresult(result); let expanded_results = PsbQaqcResult::from_masterlogresult(result);
let mut wtr = match (outfile.exists(), nonewfile) { let mut wtr = match outfile.exists() {
(true, false) => { true => {
let file = File::options() let file = File::options()
.read(true) .read(true)
.append(true) .append(true)
@ -365,7 +364,7 @@ fn write_psbqaqc_csv(result: MasterLogResult, outfile: PathBuf, nonewfile: bool)
.has_headers(false) .has_headers(false)
.from_writer(file) .from_writer(file)
} }
(false, _) => { false => {
println!("Creating new file: {}", outfile.display()); println!("Creating new file: {}", outfile.display());
let file = File::options() let file = File::options()
.create_new(true) .create_new(true)
@ -375,10 +374,6 @@ fn write_psbqaqc_csv(result: MasterLogResult, outfile: PathBuf, nonewfile: bool)
.has_headers(true) .has_headers(true)
.from_writer(file) .from_writer(file)
} }
(true, true) => {
error!("Out file already exists but specified not to make new file");
return Err(anyhow!("Out file already exists"));
}
}; };
for result in expanded_results { for result in expanded_results {
wtr.serialize(result)?; wtr.serialize(result)?;
@ -414,7 +409,7 @@ fn main() -> Result<()> {
let outfile = outfile.unwrap_or(get_output_filename(&result)); let outfile = outfile.unwrap_or(get_output_filename(&result));
write_psbqaqc_csv(result, outfile.clone(), true)?; write_psbqaqc_csv(result, outfile.clone())?;
println!("Add comments about errors in the last column of the CSV file"); println!("Add comments about errors in the last column of the CSV file");
println!("Press any key to start editting..."); println!("Press any key to start editting...");
@ -433,17 +428,14 @@ fn main() -> Result<()> {
editor editor
} }
(None, Err(e1), Err(e2)) => { (None, Err(e1), Err(e2)) => {
warn!("No VISUAL nor EDITOR found, {}, {}", e1, e2); info!("No VISUAL nor EDITOR found, {}, {}", e1, e2);
warn!("Using `nano` as a fallback editor");
"nano".to_string() "nano".to_string()
} }
}; };
std::process::Command::new(editor) std::process::Command::new(editor)
.arg(outfile.clone()) .arg(outfile.clone())
.spawn() .spawn()?
.context("Error during spawning editor")? .wait()?;
.wait()
.context("Error while waiting editor")?;
{ {
let f = File::open(outfile.clone())?; let f = File::open(outfile.clone())?;
@ -452,7 +444,7 @@ fn main() -> Result<()> {
} }
println!(); println!();
println!("Copy the CSV above and paste it to the database(Google sheets)"); println!("Copy the CSV above and paste it to the database(Google sheets)");
println!("Choose `Data->Split text to columns` to format it"); println!("Choose Data->Split text to columns to format it");
println!("Press any key when upload finished..."); println!("Press any key when upload finished...");
terminal::enable_raw_mode()?; terminal::enable_raw_mode()?;
@ -491,7 +483,7 @@ fn main() -> Result<()> {
let outfile = outfile.unwrap_or(get_output_filename(&result)); let outfile = outfile.unwrap_or(get_output_filename(&result));
write_psbqaqc_csv(result, outfile, false)?; write_psbqaqc_csv(result, outfile)?;
} }
Commands::CheckDB { csvfile } => { Commands::CheckDB { csvfile } => {
// TODO: more friendly message (like row number) // TODO: more friendly message (like row number)