mirror of
https://github.com/nushell/nushell.git
synced 2025-01-13 09:48:30 +01:00
Add and remove env var behavior appears correct
However, it does not use existing code that well.
This commit is contained in:
parent
0728c23ec0
commit
3aeddee2fe
18
crates/nu-cli/src/env/environment.rs
vendored
18
crates/nu-cli/src/env/environment.rs
vendored
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
1
crates/nu-cli/src/env/environment_syncer.rs
vendored
1
crates/nu-cli/src/env/environment_syncer.rs
vendored
@ -71,6 +71,7 @@ impl EnvironmentSyncer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub fn sync_path_vars(&mut self, ctx: &mut Context) {
|
||||
|
Loading…
Reference in New Issue
Block a user