mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user