use mars_raw_utils::{ constants, print, vprintln, path, m20 }; use rayon::prelude::*; #[macro_use] extern crate clap; use clap::{Arg, App}; fn main() { let matches = App::new(crate_name!()) .version(crate_version!()) .author(crate_authors!()) .arg(Arg::with_name(constants::param::PARAM_INPUTS) .short(constants::param::PARAM_INPUTS_SHORT) .long(constants::param::PARAM_INPUTS) .value_name("INPUT") .help("Input") .required(true) .multiple(true) .takes_value(true)) .arg(Arg::with_name(constants::param::PARAM_CAL_PROFILE) .short(constants::param::PARAM_CAL_PROFILE_SHORT) .long(constants::param::PARAM_CAL_PROFILE) .value_name("PARAM_CAL_PROFILE") .help("Calibration profile file path") .required(false) .multiple(true) .takes_value(true)) .arg(Arg::with_name(constants::param::PARAM_VERBOSE) .short(constants::param::PARAM_VERBOSE) .help("Show verbose output")) .arg(Arg::with_name(constants::param::PARAM_ONLY_NEW) .short(constants::param::PARAM_ONLY_NEW_SHORT) .help("Only new images. Skipped processed images.")) .get_matches(); if matches.is_present(constants::param::PARAM_VERBOSE) { print::set_verbose(true); } let mut only_new = false; if matches.is_present(constants::param::PARAM_ONLY_NEW) { only_new = true; } let filename_suffix: String = String::from(constants::OUTPUT_FILENAME_APPEND); let profiles: Vec<&str> = match matches.values_of(constants::param::PARAM_CAL_PROFILE) { Some(profiles) => profiles.collect(), None => vec!() }; let input_files: Vec<&str> = matches.values_of(constants::param::PARAM_INPUTS).unwrap().collect(); let num_files = input_files.len(); input_files.into_par_iter().enumerate().for_each(|(idx, in_file)| { if path::file_exists(in_file) { vprintln!("Processing File: {} (#{} of {})", in_file, idx, num_files); m20::helinav::process_with_profiles(in_file, only_new, &filename_suffix, &profiles); } else { eprintln!("File not found: {}", in_file); } }); }