From 1c11fec8039296632ba3eb67957e0c55d2385837 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 1 Oct 2018 20:53:41 -0700 Subject: [PATCH] Move hardcoded string file names into vars --- schala-repl/src/repl.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/schala-repl/src/repl.rs b/schala-repl/src/repl.rs index 7a8ae36..4ff75ef 100644 --- a/schala-repl/src/repl.rs +++ b/schala-repl/src/repl.rs @@ -7,6 +7,9 @@ use itertools::Itertools; use language::{ProgrammingLanguageInterface, EvalOptions, PassDebugOptionsDescriptor}; +const HISTORY_SAVE_FILE: &'static str = ".schala_history"; +const OPTIONS_SAVE_FILE: &'static str = ".schala_repl"; + pub struct Repl { options: EvalOptions, languages: Vec>, @@ -36,7 +39,7 @@ impl Repl { } fn get_options() -> EvalOptions { - File::open(".schala_repl") + File::open(OPTIONS_SAVE_FILE) .and_then(|mut file| { let mut contents = String::new(); file.read_to_string(&mut contents)?; @@ -50,14 +53,14 @@ impl Repl { fn save_options(&self) { let ref options = self.options; - let read = File::create(".schala_repl") + let read = File::create(OPTIONS_SAVE_FILE) .and_then(|mut file| { let buf = ::serde_json::to_string(options).unwrap(); file.write_all(buf.as_bytes()) }); if let Err(err) = read { - println!("Error saving .schala_repl file {}", err); + println!("Error saving {} file {}", OPTIONS_SAVE_FILE, err); } } @@ -67,7 +70,7 @@ impl Repl { println!("Schala MetaInterpreter version {}", ::VERSION_STRING); println!("Type {}help for help with the REPL", self.interpreter_directive_sigil); - self.line_reader.load_history(".schala_history").unwrap_or(()); + self.line_reader.load_history(HISTORY_SAVE_FILE).unwrap_or(()); loop { let language_name = self.get_cur_language().get_language_name(); @@ -96,7 +99,7 @@ impl Repl { } } } - self.line_reader.save_history(".schala_history").unwrap_or(()); + self.line_reader.save_history(HISTORY_SAVE_FILE).unwrap_or(()); self.save_options(); println!("Exiting..."); }