Add unlet_env command (#3629)

* Add ability to remove env variables

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Implement unlet_env command

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Update parameter description

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Migrate to new filestructure

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Added tests for unlet-env

Signed-off-by: nathom <nathanthomas707@gmail.com>

* Formatting

Signed-off-by: nathom <nathanthomas707@gmail.com>
This commit is contained in:
Nathan Thomas
2021-06-18 20:00:07 -07:00
committed by GitHub
parent 26899bc0f0
commit 9e39284de9
5 changed files with 96 additions and 0 deletions

View File

@ -239,6 +239,15 @@ impl Scope {
}
}
pub fn remove_env_var(&self, name: impl Into<String>) -> Option<String> {
if let Some(frame) = self.frames.lock().last_mut() {
if let Some(val) = frame.env.remove_entry(&name.into()) {
return Some(val.1);
}
}
None
}
pub fn add_env(&self, env_vars: IndexMap<String, String>) {
if let Some(frame) = self.frames.lock().last_mut() {
frame.env.extend(env_vars)