use super::Evolver;

impl Evolver {
    /// Changes setting.
    pub fn set(&mut self, setting: &str, valstr: &str) -> Result<(), String> {
        match setting {
            "log" => {
                match valstr {
                    "off" => {
                        self.settings.log = false;
                        Ok(())
                    }
                    "on" => {
                        self.settings.log = true;
                        Ok(())
                    },
                    _ => {
                        Err(String::from("Unknown value of setting"))
                    }
                }
            },

            "test" => {
                match valstr {
                    "new" => {
                        self.settings.test_all = false;
                        Ok(())
                    }
                    "all" => {
                        self.settings.test_all = true;
                        Ok(())
                    },
                    _ => {
                        Err(String::from("Unknown value of setting"))
                    }
                }
            },

            "print" => {
                match valstr {
                    "improve" => {
                        self.settings.print_epochs_all = false;
                        Ok(())
                    }
                    "all" => {
                        self.settings.print_epochs_all = true;
                        Ok(())
                    },
                    _ => {
                        Err(String::from("Unknown value of setting"))
                    }
                }
            },

            _ => {
                Err(String::from("Unknown setting"))
            }
        }
    }


}
