Add func to command
This commit is contained in:
parent
0451676ba7
commit
6d88447458
@ -37,8 +37,7 @@ impl Repl {
|
|||||||
|
|
||||||
self.handle_repl_loop();
|
self.handle_repl_loop();
|
||||||
|
|
||||||
self.line_reader.save_history(HISTORY_SAVE_FILE).unwrap_or(());
|
self.save_before_exit();
|
||||||
self.save_options();
|
|
||||||
|
|
||||||
println!("Exiting...");
|
println!("Exiting...");
|
||||||
}
|
}
|
||||||
@ -75,8 +74,10 @@ impl Repl {
|
|||||||
self.line_reader.set_prompt(&prompt_str).unwrap();
|
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 ref options = self.options;
|
||||||
let read = File::create(OPTIONS_SAVE_FILE)
|
let read = File::create(OPTIONS_SAVE_FILE)
|
||||||
.and_then(|mut file| {
|
.and_then(|mut file| {
|
||||||
@ -87,6 +88,7 @@ impl Repl {
|
|||||||
if let Err(err) = read {
|
if let Err(err) = read {
|
||||||
println!("Error saving {} file {}", OPTIONS_SAVE_FILE, err);
|
println!("Error saving {} file {}", OPTIONS_SAVE_FILE, err);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +142,10 @@ impl Repl {
|
|||||||
|
|
||||||
CommandTree::Top(vec![
|
CommandTree::Top(vec![
|
||||||
CommandTree::term("exit", Some("exit the REPL")),
|
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::term("help", Some("Print this help message")),
|
||||||
CommandTree::nonterm("debug",
|
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"),
|
Some("show or hide pass debug info for a given pass, or display the names of all passes, or turn timing on/off"),
|
||||||
|
Loading…
Reference in New Issue
Block a user