use std::{env, fs, io, time::Duration};
fn main() -> io::Result<()> {
let path = env::args_os()
.nth(1)
.ok_or_else(|| io::Error::other("supply a calibration TSV"))?;
let samples = fs::read_to_string(path)?
.lines()
.map(|line| {
let (depth, microseconds) = line
.split_once('\t')
.ok_or_else(|| io::Error::other("expected depth and microseconds"))?;
let depth = depth.parse().map_err(io::Error::other)?;
let time = Duration::from_micros(microseconds.parse().map_err(io::Error::other)?);
Ok((depth, time))
})
.collect::<io::Result<Vec<_>>>()?;
println!("{}", rustsy_engine::pipeline::select_depth(&samples));
Ok(())
}