File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ clap = "2.31.2"
13
13
rustpython_parser = {path = " parser" }
14
14
rustpython_vm = {path = " vm" }
15
15
rustyline = " 2.1.0"
16
+ xdg = " 2.2.0"
16
17
17
18
[profile .release ]
18
19
opt-level = " s"
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ extern crate log;
7
7
extern crate rustpython_parser;
8
8
extern crate rustpython_vm;
9
9
extern crate rustyline;
10
+ extern crate xdg;
10
11
11
12
use clap:: { App , Arg } ;
12
13
use rustpython_parser:: parser;
@@ -154,9 +155,10 @@ fn run_shell(vm: &mut VirtualMachine) -> PyResult {
154
155
let mut input = String :: new ( ) ;
155
156
let mut rl = Editor :: < ( ) > :: new ( ) ;
156
157
157
- // TODO: Store the history in a proper XDG directory
158
- let repl_history_path = ".repl_history.txt" ;
159
- if rl. load_history ( repl_history_path) . is_err ( ) {
158
+ let xdg_dirs = xdg:: BaseDirectories :: with_prefix ( "rustpython" ) . unwrap ( ) ;
159
+ let repl_history_path = xdg_dirs. place_cache_file ( "repl_history.txt" ) . unwrap ( ) ;
160
+ let repl_history_path_str = repl_history_path. to_str ( ) . unwrap ( ) ;
161
+ if rl. load_history ( repl_history_path_str) . is_err ( ) {
160
162
println ! ( "No previous history." ) ;
161
163
}
162
164
@@ -220,7 +222,7 @@ fn run_shell(vm: &mut VirtualMachine) -> PyResult {
220
222
}
221
223
} ;
222
224
}
223
- rl. save_history ( repl_history_path ) . unwrap ( ) ;
225
+ rl. save_history ( repl_history_path_str ) . unwrap ( ) ;
224
226
225
227
Ok ( vm. get_none ( ) )
226
228
}
You can’t perform that action at this time.
0 commit comments