File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ clap = "2.31.2"
1313rustpython_parser = {path = " parser" }
1414rustpython_vm = {path = " vm" }
1515rustyline = " 2.1.0"
16+ xdg = " 2.2.0"
1617
1718[profile .release ]
1819opt-level = " s"
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ extern crate log;
77extern crate rustpython_parser;
88extern crate rustpython_vm;
99extern crate rustyline;
10+ extern crate xdg;
1011
1112use clap:: { App , Arg } ;
1213use rustpython_parser:: parser;
@@ -154,9 +155,10 @@ fn run_shell(vm: &mut VirtualMachine) -> PyResult {
154155 let mut input = String :: new ( ) ;
155156 let mut rl = Editor :: < ( ) > :: new ( ) ;
156157
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 ( ) {
160162 println ! ( "No previous history." ) ;
161163 }
162164
@@ -220,7 +222,7 @@ fn run_shell(vm: &mut VirtualMachine) -> PyResult {
220222 }
221223 } ;
222224 }
223- rl. save_history ( repl_history_path ) . unwrap ( ) ;
225+ rl. save_history ( repl_history_path_str ) . unwrap ( ) ;
224226
225227 Ok ( vm. get_none ( ) )
226228}
You can’t perform that action at this time.
0 commit comments