aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2019-06-23 12:46:56 +0100
committerNerdyPepper <[email protected]>2019-06-23 12:46:56 +0100
commitd2d80030c1eaae9f08fb6a51c4159eed009086b6 (patch)
tree8003c015e6f2c6a8fdb42a5299e7aa2714e020b4 /src
parentf869c6a1977146b71069fc137bcd4d5644ce60c6 (diff)
remove unused imports, closes #16 and #17
Diffstat (limited to 'src')
-rw-r--r--src/main.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index d6883d5..10ae251 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,7 +6,8 @@
6 6
7// std 7// std
8use std::f64; 8use std::f64;
9use std::borrow::Cow::{self, Borrowed, Owned}; 9use std::borrow::Cow::{self,Owned};
10use std::path::PathBuf;
10 11
11// modules 12// modules
12mod lex; 13mod lex;
@@ -24,12 +25,11 @@ use rustyline::{ Editor, Context, Helper };
24use rustyline::config::{ Builder, ColorMode, EditMode, CompletionType }; 25use rustyline::config::{ Builder, ColorMode, EditMode, CompletionType };
25use rustyline::hint::Hinter; 26use rustyline::hint::Hinter;
26use rustyline::completion::{ FilenameCompleter, Completer, Pair }; 27use rustyline::completion::{ FilenameCompleter, Completer, Pair };
27use rustyline::highlight::{ Highlighter, MatchingBracketHighlighter }; 28use rustyline::highlight::Highlighter;
28 29
29use clap::{Arg, App}; 30use clap::{Arg, App};
30use lazy_static::lazy_static; 31use lazy_static::lazy_static;
31 32
32
33struct RLHelper { 33struct RLHelper {
34 completer: FilenameCompleter, 34 completer: FilenameCompleter,
35 highlighter: LineHighlighter, 35 highlighter: LineHighlighter,
@@ -131,7 +131,15 @@ fn main() {
131 hinter: AnswerHinter {} 131 hinter: AnswerHinter {}
132 }; 132 };
133 rl.set_helper(Some(h)); 133 rl.set_helper(Some(h));
134 if rl.load_history("history.txt").is_err() { 134 let mut history_path = PathBuf::new();
135 match dirs::home_dir() {
136 Some(p) => {
137 history_path = p;
138 history_path.push("history.txt");
139 },
140 None => history_path.set_file_name("history.txt"),
141 };
142 if rl.load_history(history_path.as_path()).is_err() {
135 println!("No previous history.") 143 println!("No previous history.")
136 }; 144 };
137 145
@@ -151,7 +159,6 @@ fn main() {
151 break 159 break
152 }, 160 },
153 Err(ReadlineError::Eof) => { 161 Err(ReadlineError::Eof) => {
154 println!("CTRL-D");
155 break 162 break
156 }, 163 },
157 Err(err) => { 164 Err(err) => {
@@ -160,7 +167,7 @@ fn main() {
160 } 167 }
161 } 168 }
162 } 169 }
163 rl.save_history("history.txt").unwrap(); 170 rl.save_history(history_path.as_path()).unwrap();
164 } 171 }
165} 172}
166 173