Add args in .nurc file to environment

This commit is contained in:
Sam Hedin 2020-06-04 01:07:39 +02:00
parent b6f9d0ca58
commit 83795a3e70
2 changed files with 14 additions and 0 deletions

View File

@ -3,6 +3,8 @@ use indexmap::{indexmap, IndexSet};
use nu_protocol::{UntaggedValue, Value}; use nu_protocol::{UntaggedValue, Value};
use std::ffi::OsString; use std::ffi::OsString;
use std::fmt::Debug; use std::fmt::Debug;
use std::fs::File;
use std::io::Write;
pub trait Env: Debug + Send { pub trait Env: Debug + Send {
fn env(&self) -> Option<Value>; fn env(&self) -> Option<Value>;
@ -44,6 +46,16 @@ impl Environment {
} }
} }
pub fn add_nurc(&mut self) {
let key = "envtest";
let value = "I am here!";
let mut file = File::create("env.txt").unwrap();
write!(&mut file, "{:?}", "somedata").unwrap();
self.add_env(key, value);
}
pub fn from_config<T: Conf>(configuration: &T) -> Environment { pub fn from_config<T: Conf>(configuration: &T) -> Environment {
let env = configuration.env(); let env = configuration.env();
let path = configuration.path(); let path = configuration.path();

View File

@ -70,6 +70,8 @@ impl EnvironmentSyncer {
} }
} }
} }
environment.add_nurc();
} }
pub fn sync_path_vars(&mut self, ctx: &mut Context) { pub fn sync_path_vars(&mut self, ctx: &mut Context) {