Init autoenv command

This commit is contained in:
Sam Hedin 2020-06-18 07:36:53 +02:00
parent a173817889
commit 35bb9f2d1e
2 changed files with 34 additions and 2 deletions

View File

@ -0,0 +1,30 @@
use crate::commands::WholeStreamCommand;
use crate::prelude::*;
use nu_errors::ShellError;
use nu_protocol::{Primitive, ReturnSuccess, UntaggedValue, Value};
pub struct Autoenv;
#[async_trait]
impl WholeStreamCommand for Autoenv {
fn name(&self) -> &str {
"autoenv"
}
fn usage(&self) -> &str {
"Mark a .nu-env file in a directory as trusted. Needs to be re-made after each change to the file."
}
async fn run(
&self,
args: CommandArgs,
registry: &CommandRegistry,
) -> Result<OutputStream, ShellError> {
allow(args, registry).await
}
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Allow .nu-env file in current directory",
example: "autoenv trust",
result: "Current "
}]
}
}

View File

@ -27,5 +27,7 @@ returning =None=, which completely skips running the code for dealing with direc
- Add command to clear allowed .nu-envs in a directory.
** Nice errors
** Potential issues
- Functionality to re-add overwritten variables is currently untested.
- Needs to be tested with what happens if you set a variable in the current session from some other source than .nu-env or config.toml
There was previously functionality to track overwritten environment variables, which was used to restore any values that are overwritten.
However, it seems that with the current version the already existing nushell functionality takes care of this, in every case I can come up with.
Because of that, I just removed the code. It's still there, in the venerable git log if anything ever changes `acd3215b` `Remove overwritten values tracking, as it is not needed`.
(I am making a note of this as I half expect someone to come up with a scenario which requires this to be re-added.)