Skip to content

Commit 1cf7b61

Browse files
committed
Refactor REPL history path handling
- Simplified the `repl_history_path` function by directly using `dirs::data_local_dir()` for path resolution, removing the platform-specific state directory checks. - This change streamlines the REPL history management, ensuring consistent behavior across platforms while maintaining the functionality of saving command history.
1 parent 6932db5 commit 1cf7b61

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

src/bin/datu/repl.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,8 @@ use rustyline::error::ReadlineError;
1111
/// Maximum number of inputs to keep in REPL history.
1212
const HISTORY_DEPTH: usize = 1000;
1313

14-
#[cfg(any(
15-
target_os = "android",
16-
target_os = "dragonfly",
17-
target_os = "freebsd",
18-
target_os = "linux",
19-
target_os = "netbsd",
20-
target_os = "openbsd",
21-
target_os = "redox",
22-
))]
23-
fn platform_state_dir() -> Option<PathBuf> {
24-
dirs::state_dir()
25-
}
26-
27-
#[cfg(not(any(
28-
target_os = "android",
29-
target_os = "dragonfly",
30-
target_os = "freebsd",
31-
target_os = "linux",
32-
target_os = "netbsd",
33-
target_os = "openbsd",
34-
target_os = "redox",
35-
)))]
36-
fn platform_state_dir() -> Option<PathBuf> {
37-
None
38-
}
39-
4014
fn repl_history_path() -> Option<PathBuf> {
41-
platform_state_dir()
42-
.or_else(dirs::data_local_dir)
43-
.map(|dir| dir.join("datu").join("history"))
15+
dirs::data_local_dir().map(|dir| dir.join("datu").join("history"))
4416
}
4517

4618
fn load_repl_history(rl: &mut DefaultEditor) -> Result<()> {

0 commit comments

Comments
 (0)