diff --git a/schala-repl/src/repl/mod.rs b/schala-repl/src/repl/mod.rs index 62c3314..efab953 100644 --- a/schala-repl/src/repl/mod.rs +++ b/schala-repl/src/repl/mod.rs @@ -37,8 +37,7 @@ impl Repl { self.handle_repl_loop(); - self.line_reader.save_history(HISTORY_SAVE_FILE).unwrap_or(()); - self.save_options(); + self.save_before_exit(); println!("Exiting..."); } @@ -75,8 +74,10 @@ impl Repl { self.line_reader.set_prompt(&prompt_str).unwrap(); } - fn save_options(&self) { + fn save_before_exit(&self) { + self.line_reader.save_history(HISTORY_SAVE_FILE).unwrap_or(()); /* + self.save_options() { let ref options = self.options; let read = File::create(OPTIONS_SAVE_FILE) .and_then(|mut file| { @@ -87,6 +88,7 @@ impl Repl { if let Err(err) = read { println!("Error saving {} file {}", OPTIONS_SAVE_FILE, err); } + } */ } @@ -140,7 +142,10 @@ impl Repl { CommandTree::Top(vec![ CommandTree::term("exit", Some("exit the REPL")), - CommandTree::term("quit", Some("exit the REPL")), + CommandTree::term_with_function("quit", Some("exit the REPL"), Box::new(|repl: &mut Repl, cmds: Vec| { + repl.save_before_exit(); + ::std::process::exit(0) + })), CommandTree::term("help", Some("Print this help message")), CommandTree::nonterm("debug", Some("show or hide pass debug info for a given pass, or display the names of all passes, or turn timing on/off"),