mirror of
https://github.com/nushell/nushell.git
synced 2025-03-21 19:17:48 +01:00
We split off the evaluation engine part of nu-cli into its own crate. This helps improve build times for nu-cli by 17% in my tests. It also helps us see a bit better what's the core engine portion vs the part specific to the interactive CLI piece. There's more than can be done here, but I think it's a good start in the right direction.
23 lines
606 B
Rust
23 lines
606 B
Rust
use nu_data::config::Conf;
|
|
use std::path::PathBuf;
|
|
|
|
const DEFAULT_LOCATION: &str = "history.txt";
|
|
|
|
pub fn history_path(config: &dyn Conf) -> PathBuf {
|
|
let default_path = nu_data::config::user_data()
|
|
.map(|mut p| {
|
|
p.push(DEFAULT_LOCATION);
|
|
p
|
|
})
|
|
.unwrap_or_else(|_| PathBuf::from(DEFAULT_LOCATION));
|
|
|
|
config
|
|
.var("history-path")
|
|
.map_or(default_path.clone(), |custom_path| {
|
|
match custom_path.as_string() {
|
|
Ok(path) => PathBuf::from(path),
|
|
Err(_) => default_path,
|
|
}
|
|
})
|
|
}
|