Add and remove env var behavior appears correct

However, it does not use existing code that well.
This commit is contained in:
Sam Hedin 2020-06-04 23:43:26 +02:00
parent 0728c23ec0
commit 3aeddee2fe
2 changed files with 2 additions and 17 deletions

View File

@ -4,11 +4,9 @@ use nu_protocol::{UntaggedValue, Value};
use std::collections::{HashMap};
use std::ffi::OsString;
use std::fmt::Debug;
use std::fs::OpenOptions;
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
use std::io::Write;
pub trait Env: Debug + Send {
fn env(&self) -> Option<Value>;
@ -87,14 +85,6 @@ impl Environment {
let toml_doc = contents.parse::<toml::Value>().unwrap();
let nurc_vars = toml_doc.get("env").unwrap().as_table().unwrap();
let mut file = OpenOptions::new()
.write(true)
.append(true)
.create(true)
.open("env.txt").unwrap();
write!(&mut file, "keys to add: {:?}\n", nurc_vars).unwrap();
nurc_vars.iter().for_each(|(k, v)| {
self.add_env(k, v.as_str().unwrap());
});
@ -133,13 +123,6 @@ impl Environment {
}
}
let mut file = OpenOptions::new()
.write(true)
.append(true)
.create(true)
.open("env.txt")?;
write!(&mut file, "keys to remove: {:?}\n", vars_to_delete).unwrap();
vars_to_delete.iter().for_each(|env_var| self.remove_env(env_var));
self.nurc_env_keys = new_nurc_env_vars;
@ -154,6 +137,7 @@ impl Environment {
{
envs.entries.remove(key);
std::env::remove_var(key);
}
}

View File

@ -71,6 +71,7 @@ impl EnvironmentSyncer {
}
}
}
}
pub fn sync_path_vars(&mut self, ctx: &mut Context) {