Add func to command

This commit is contained in:
greg 2019-03-14 04:08:32 -07:00
parent 0451676ba7
commit 6d88447458
1 changed files with 9 additions and 4 deletions

View File

@ -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<String>| {
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"),