Rename direnv to autoenv

This commit is contained in:
Sam Hedin 2020-06-24 00:07:00 +02:00
parent 21ebfca368
commit 4bebfa2762
3 changed files with 8 additions and 8 deletions

View File

@ -47,7 +47,7 @@ impl DirectorySpecificEnvironment {
})?);
}
return Err(ShellError::untagged_runtime_error(
format!("{:?} is untrusted. Run 'autoenv trust {:?}' and restart nushell to trust it.\nThis needs to be done after each change to the file.", wdirenv, wdirenv.parent().unwrap_or_else(|| &Path::new("")))));
format!("{:?} is untrusted. Run 'autoenv trust {:?}' and restart nushell to trust it.\nThis needs to be done after each change to the file.\n", wdirenv, wdirenv.parent().unwrap_or_else(|| &Path::new("")))));
}
Err(ShellError::untagged_runtime_error("No trusted directories"))
}

View File

@ -36,7 +36,7 @@ impl Env for Box<dyn Env> {
pub struct Environment {
environment_vars: Option<Value>,
path_vars: Option<Value>,
pub direnv: DirectorySpecificEnvironment,
pub autoenv: DirectorySpecificEnvironment,
}
impl Environment {
@ -44,7 +44,7 @@ impl Environment {
Environment {
environment_vars: None,
path_vars: None,
direnv: DirectorySpecificEnvironment::new(),
autoenv: DirectorySpecificEnvironment::new(),
}
}
@ -54,16 +54,16 @@ impl Environment {
Environment {
environment_vars: env,
path_vars: path,
direnv: DirectorySpecificEnvironment::new(),
autoenv: DirectorySpecificEnvironment::new(),
}
}
pub fn maintain_directory_environment(&mut self) -> Result<(), ShellError> {
self.direnv.env_vars_to_delete()?.iter().for_each(|k| {
pub fn autoenv(&mut self) -> Result<(), ShellError> {
self.autoenv.env_vars_to_delete()?.iter().for_each(|k| {
self.remove_env(&k);
});
self.direnv.env_vars_to_add()?.iter().for_each(|(k, v)| {
self.autoenv.env_vars_to_add()?.iter().for_each(|(k, v)| {
self.add_env(&k, &v.to_string_lossy(), true);
});
Ok(())

View File

@ -45,7 +45,7 @@ impl EnvironmentSyncer {
pub fn sync_env_vars(&mut self, ctx: &mut Context) {
let mut environment = self.env.lock();
if let Err(e) = environment.maintain_directory_environment() {
if let Err(e) = environment.autoenv() {
crate::cli::print_err(e, &Text::from(""));
}
if environment.env().is_some() {