Get $nu.config-path and $nu.env-path from EngineState (#6366)

* Get `$nu.config-path` and `$nu.env-path` from `EngineState`

Signed-off-by: nibon7 <nibon7@163.com>

* replace tuple with hashmap

Signed-off-by: nibon7 <nibon7@163.com>

* refactor set_config_path

Signed-off-by: nibon7 <nibon7@163.com>

Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
nibon7
2022-08-23 00:30:09 +08:00
committed by GitHub
parent 9c4bbe3c63
commit 772ad896c8
3 changed files with 83 additions and 13 deletions

View File

@ -76,6 +76,7 @@ pub struct EngineState {
pub plugin_signatures: Option<PathBuf>,
#[cfg(not(windows))]
sig_quit: Option<Arc<AtomicBool>>,
config_path: HashMap<String, PathBuf>,
}
pub const NU_VARIABLE_ID: usize = 0;
@ -113,6 +114,7 @@ impl EngineState {
plugin_signatures: None,
#[cfg(not(windows))]
sig_quit: None,
config_path: HashMap::new(),
}
}
@ -753,6 +755,14 @@ impl EngineState {
pub fn set_sig_quit(&mut self, sig_quit: Arc<AtomicBool>) {
self.sig_quit = Some(sig_quit)
}
pub fn set_config_path(&mut self, key: &str, val: PathBuf) {
self.config_path.insert(key.to_string(), val);
}
pub fn get_config_path(&self, key: &str) -> Option<&PathBuf> {
self.config_path.get(key)
}
}
/// A temporary extension to the global state. This handles bridging between the global state and the