use crate::{Config, Zoom};
use std::fs::File;

pub struct InputArguments {
    pub input_file: File,
    pub output_file: File,
    pub config: Option<Config>,
    pub process: Option<String>,
}

/// The input arguments used for processing
///
/// # Example
///
/// ```
/// use tilemake_rs::InputArguments;
/// use std::path::Path;
/// use std::fs::File;
///
/// let input_file = File::open(Path::new("tests/data/azores-260318-power.osm.pbf")).unwrap();
/// let output_file = File::create(Path::new("tests/data/output.pmtiles")).unwrap();
/// let input_arguments = InputArguments::new(input_file, output_file);
/// ```
impl InputArguments {
    pub fn new(input_file: File, output_file: File) -> Self {
        Self {
            input_file,
            output_file,
            config: None,
            process: None,
        }
    }

    pub fn set_config(&mut self, config: Option<Config>) {
        self.config = config;
    }

    pub fn set_process(&mut self, process: Option<String>) {
        self.process = process;
    }

    pub fn zoom_iter(&self) -> impl Iterator<Item = Zoom> {
        let mut min = 0;
        let mut max = 14;

        if let Some(config) = &self.config {
            min = config.settings.minzoom;
            max = config.settings.maxzoom;
        }

        min..=max
    }
}
