From 83795a3e7090fe88fc3c334cb413b921bbc3d96c Mon Sep 17 00:00:00 2001 From: Sam Hedin Date: Thu, 4 Jun 2020 01:07:39 +0200 Subject: [PATCH] Add args in .nurc file to environment --- crates/nu-cli/src/env/environment.rs | 12 ++++++++++++ crates/nu-cli/src/env/environment_syncer.rs | 2 ++ 2 files changed, 14 insertions(+) diff --git a/crates/nu-cli/src/env/environment.rs b/crates/nu-cli/src/env/environment.rs index 9b586eded2..d0286e1a71 100644 --- a/crates/nu-cli/src/env/environment.rs +++ b/crates/nu-cli/src/env/environment.rs @@ -3,6 +3,8 @@ use indexmap::{indexmap, IndexSet}; use nu_protocol::{UntaggedValue, Value}; use std::ffi::OsString; use std::fmt::Debug; +use std::fs::File; +use std::io::Write; pub trait Env: Debug + Send { fn env(&self) -> Option; @@ -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(configuration: &T) -> Environment { let env = configuration.env(); let path = configuration.path(); diff --git a/crates/nu-cli/src/env/environment_syncer.rs b/crates/nu-cli/src/env/environment_syncer.rs index 852ccfa75c..50f644cf23 100644 --- a/crates/nu-cli/src/env/environment_syncer.rs +++ b/crates/nu-cli/src/env/environment_syncer.rs @@ -70,6 +70,8 @@ impl EnvironmentSyncer { } } } + + environment.add_nurc(); } pub fn sync_path_vars(&mut self, ctx: &mut Context) {