mirror of
https://github.com/nushell/nushell.git
synced 2025-06-09 11:36:52 +02:00
27 lines
976 B
Rust
27 lines
976 B
Rust
use crate::EvaluationContext;
|
|
use crate::Scope;
|
|
use crate::{basic_shell_manager, config_holder::ConfigHolder};
|
|
use crate::{env::basic_host::BasicHost, Host};
|
|
use indexmap::IndexMap;
|
|
use parking_lot::Mutex;
|
|
use std::error::Error;
|
|
use std::sync::atomic::AtomicBool;
|
|
use std::sync::Arc;
|
|
|
|
pub fn basic_evaluation_context() -> Result<EvaluationContext, Box<dyn Error>> {
|
|
let scope = Scope::new();
|
|
let mut host = BasicHost {};
|
|
let env_vars = host.vars().iter().cloned().collect::<IndexMap<_, _>>();
|
|
scope.add_env(env_vars);
|
|
|
|
Ok(EvaluationContext {
|
|
scope,
|
|
host: Arc::new(parking_lot::Mutex::new(Box::new(host))),
|
|
current_errors: Arc::new(Mutex::new(vec![])),
|
|
ctrl_c: Arc::new(AtomicBool::new(false)),
|
|
configs: Arc::new(Mutex::new(ConfigHolder::new())),
|
|
shell_manager: basic_shell_manager::basic_shell_manager()?,
|
|
windows_drives_previous_cwd: Arc::new(Mutex::new(std::collections::HashMap::new())),
|
|
})
|
|
}
|