From 6d88447458e9982205f3a18a97aaad9b0f0e8f7a Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 14 Mar 2019 04:08:32 -0700 Subject: [PATCH] Add func to command --- schala-repl/src/repl/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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"),